Welcome to WebmasterWorld Guest from 54.242.94.72

Forum Moderators: open

Message Too Old, No Replies

Help with syntax error on mysql statement.

     

nelsonm

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

5+ Year Member



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.

penders

9:00 pm on Sep 14, 2011 (gmt 0)

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



Have you tried running the query in phpMyAdmin?

nelsonm

12:17 am on Sep 15, 2011 (gmt 0)

5+ Year Member



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.

nelsonm

3:17 am on Sep 15, 2011 (gmt 0)

5+ Year Member



Just a note....

The exact same thing as a SELECT FROM WHERE also works.

arms

12:45 pm on Sep 15, 2011 (gmt 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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month