homepage Welcome to WebmasterWorld Guest from 23.23.57.144
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Help with syntax error on mysql statement.
nelsonm

5+ Year Member



 
Msg#: 4362544 posted 7:33 pm on Sep 14, 2011 (gmt 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.

 

penders

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



 
Msg#: 4362544 posted 9:00 pm on Sep 14, 2011 (gmt 0)

Have you tried running the query in phpMyAdmin?

nelsonm

5+ Year Member



 
Msg#: 4362544 posted 12:17 am on Sep 15, 2011 (gmt 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.

nelsonm

5+ Year Member



 
Msg#: 4362544 posted 3:17 am on Sep 15, 2011 (gmt 0)

Just a note....

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

arms



 
Msg#: 4362544 posted 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved