Join syntax problem

Join syntax problem

am 27.04.2010 01:36:13 von gary

I cant seem to get this working.

$query="SELECT im.image_id, im.caption, im.where_taken, im.description,
im.image_file, im.submitted, kw.fox, kw.wolves, kw.wildlife, kw.american,
kw.scenic, kw.birds, kw.africa, kw.eagles, kw.hunter" .
"FROM *images AS im"."JOIN keywords AS kw USING (image_id)" .
"WHERE ky.image_id = im.image_id";

Gets me this error message.

You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'keywords AS kw
USING (image_id)WHERE ky.image_id = im.image_id' at line 1

Anyone see where I am going wrong?

Thank you.

Gary



__________ Information from ESET Smart Security, version of virus signature database 5063 (20100426) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Join syntax problem

am 27.04.2010 02:35:04 von Tom Worster

On 4/26/10 7:36 PM, "Gary" wrote:

> I cant seem to get this working.
>
> $query="SELECT im.image_id, im.caption, im.where_taken, im.description,
> im.image_file, im.submitted, kw.fox, kw.wolves, kw.wildlife, kw.american,
> kw.scenic, kw.birds, kw.africa, kw.eagles, kw.hunter" .
> "FROM *images AS im"."JOIN keywords AS kw USING (image_id)" .

looks like there's no space between 'im' and 'JOIN' in the line above

> "WHERE ky.image_id = im.image_id";

try: print($query);

>
> Gets me this error message.
>
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near 'keywords AS kw
> USING (image_id)WHERE ky.image_id = im.image_id' at line 1
>
> Anyone see where I am going wrong?
>
> Thank you.
>
> Gary
>
>
>
> __________ Information from ESET Smart Security, version of virus signature
> database 5063 (20100426) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Join syntax problem

am 27.04.2010 03:18:32 von Rob Wultsch

I am reading this on a tiny screen but it looks like you need
whitespace before the where.

On 4/26/10, Gary wrote:
> I cant seem to get this working.
>
> $query="SELECT im.image_id, im.caption, im.where_taken, im.description,
> im.image_file, im.submitted, kw.fox, kw.wolves, kw.wildlife, kw.american,
> kw.scenic, kw.birds, kw.africa, kw.eagles, kw.hunter" .
> "FROM *images AS im"."JOIN keywords AS kw USING (image_id)" .
> "WHERE ky.image_id = im.image_id";
>
> Gets me this error message.
>
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near 'keywords AS kw
> USING (image_id)WHERE ky.image_id = im.image_id' at line 1
>
> Anyone see where I am going wrong?
>
> Thank you.
>
> Gary
>
>
>
> __________ Information from ESET Smart Security, version of virus signature
> database 5063 (20100426) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=wultsch@gmail.com
>
>


--
Rob Wultsch
wultsch@gmail.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Join syntax problem

am 27.04.2010 04:29:15 von gary

Thanks for the replies. It was my understanding that whitespace is ignored,
and I did not think that not having space, in particular with "." would
result in an error message.

Gary
""Gary"" wrote in message
news:20100426233621.10789.qmail@lists.mysql.com...
>I cant seem to get this working.
>
> $query="SELECT im.image_id, im.caption, im.where_taken, im.description,
> im.image_file, im.submitted, kw.fox, kw.wolves, kw.wildlife, kw.american,
> kw.scenic, kw.birds, kw.africa, kw.eagles, kw.hunter" .
> "FROM *images AS im"."JOIN keywords AS kw USING (image_id)" .
> "WHERE ky.image_id = im.image_id";
>
> Gets me this error message.
>
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near 'keywords AS kw
> USING (image_id)WHERE ky.image_id = im.image_id' at line 1
>
> Anyone see where I am going wrong?
>
> Thank you.
>
> Gary
>
>
> __________ Information from ESET Smart Security, version of virus
> signature database 5063 (20100426) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>


__________ Information from ESET NOD32 Antivirus, version of virus signature database 5063 (20100426) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

RE: Join syntax problem

am 27.04.2010 14:21:29 von Steven Staples

As Tom Worster said, print($query); would show you what the query was trying
to run.


Without testing it, you also have some other whitespace issues between the
"hw.wildlife" and "FROM", and also, i m unsure of the asterix infront of the
"*images".

On another note, when I do my "JOIN"s, I tend to write "ON
(table1.field=jointable.field)" rather than just "ON (field)".

And on a final thought, the where cause, seems to be the join clause as
well, so isn't that redundant? (or is would that only be in the way that i
said i do my joins?)


+----------------------------------------+
| Steven Staples |
+----------------------------------------+
| I may be wrong, but at least I tried...|
+----------------------------------------+



> -----Original Message-----
> From: Gary [mailto:gwp@paulgdesigns.com]
> Sent: April 26, 2010 10:29 PM
> To: mysql@lists.mysql.com
> Subject: Re: Join syntax problem
>
> Thanks for the replies. It was my understanding that whitespace is
> ignored,
> and I did not think that not having space, in particular with "." would
> result in an error message.
>
> Gary
> ""Gary"" wrote in message
> news:20100426233621.10789.qmail@lists.mysql.com...
> >I cant seem to get this working.
> >
> > $query="SELECT im.image_id, im.caption, im.where_taken,
> im.description,
> > im.image_file, im.submitted, kw.fox, kw.wolves, kw.wildlife,
> kw.american,
> > kw.scenic, kw.birds, kw.africa, kw.eagles, kw.hunter" .
> > "FROM *images AS im"."JOIN keywords AS kw USING (image_id)" .
> > "WHERE ky.image_id = im.image_id";
> >
> > Gets me this error message.
> >
> > You have an error in your SQL syntax; check the manual that
> corresponds to
> > your MySQL server version for the right syntax to use near 'keywords
> AS kw
> > USING (image_id)WHERE ky.image_id = im.image_id' at line 1
> >
> > Anyone see where I am going wrong?
> >
> > Thank you.
> >
> > Gary
> >
> >
> > __________ Information from ESET Smart Security, version of virus
> > signature database 5063 (20100426) __________
> >
> > The message was checked by ESET Smart Security.
> >
> > http://www.eset.com
> >
> >
> >
> >
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 5063 (20100426) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=sstaples@mnsi.net
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.814 / Virus Database: 271.1.1/2783 - Release Date:
> 04/26/10 02:31:00


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org