Welcome to WebmasterWorld Guest from 54.205.0.26

Forum Moderators: open

Message Too Old, No Replies

Help with syntax error on mysql statement.

     
7:33 pm on Sep 14, 2011 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


I keep getting the following error:

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 'ON (wo.CUID = cu.CUID AND wo.EMID = em.EMID)' at line 1.


on this php mysql statement:
SELECT wo.WOID, cu.LastName, em.LastName FROM `workorder` AS wo INNER JOIN `customer` AS cu, `employee` AS em ON (wo.CUID = cu.CUID AND wo.EMID = em.EMID)


As far as i can tell, i'm following the correct syntax according to the MySQL manual.

thanks.
9:00 pm on Sept 14, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


Have you tried running the query in phpMyAdmin?
12:17 am on Sept 15, 2011 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


yes, i get the same error message.

if i remove all of the second or third entries - these work.

SELECT wo.WOID, em.LastName FROM `workorder` AS wo INNER JOIN `employee` AS em ON (wo.EMID = em.EMID)



SELECT wo.WOID, cu.LastName FROM `workorder` AS wo INNER JOIN `customer` AS cu ON (wo.CUID = cu.CUID)


but this does not!
SELECT wo.WOID, cu.LastName, em.LastName FROM `workorder` AS wo INNER JOIN `customer` AS cu, `employee` AS em ON (wo.CUID = cu.CUID AND wo.EMID = em.EMID)


I'm as a loss.
3:17 am on Sept 15, 2011 (gmt 0)

Full Member

5+ Year Member

joined:June 30, 2008
posts: 318
votes: 0


Just a note....

The exact same thing as a SELECT FROM WHERE also works.
12:45 pm on Sept 15, 2011 (gmt 0)

New User

5+ Year Member

joined:Feb 22, 2011
posts:22
votes: 0


This should work:

SELECT wo.WOID, cu.LastName, em.LastName
FROM `workorder` AS wo INNER JOIN `customer` AS cu
ON wo.CUID = cu.CUID INNER JOIN `employee` AS em
ON wo.EMID = em.EMID
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members