Daniel Adarve
Daniel Adarve

Reputation: 141

MYSQL Syntax Error LEFT JOIN

Im having issues trying to figure out this syntax error. Heres the SQL query:

SQL QUERY

SELECT oh.date_modified, oh.physicianNote, os.name AS status
FROM order oh 
LEFT JOIN order_status os ON oh.order_status_id = os.order_status_id
WHERE oh.order_id = '118' AND os.language_id = '1'
ORDER BY oh.date_added ASC LIMIT 0,10

SQL ERROR

1064 - 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 'order oh LEFT JOIN order_status os ON oh.order_status_id = os.order_status_i' at line 2

Not really sure whats wrong with it.

Upvotes: 1

Views: 230

Answers (2)

Jhonathan
Jhonathan

Reputation: 1611

"ORDER" is reserved word. This is error. Use the word order Quote in backticks

Upvotes: 1

eggyal
eggyal

Reputation: 125855

ORDER is a reserved word. Quote it in backticks:

SELECT   oh.date_modified, oh.physicianNote, os.name AS status
FROM     `order` oh LEFT JOIN order_status os USING (order_status_id)
WHERE    oh.order_id = '118' AND os.language_id = '1'
ORDER BY oh.date_added
LIMIT    0,10

Upvotes: 7

Related Questions