MYSQL语法错误LEFT JOIN

时间:2012-09-14 15:38:28

标签: mysql sql

我在尝试找出此语法错误时遇到问题。继承人SQL查询:

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错误

  

1064 - 您的SQL语法出错;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近'订购哦LEFT JOIN order_status os ON oh.order_status_id =   第2行的os.order_status_i'

不确定它有什么问题。

2 个答案:

答案 0 :(得分:6)

ORDERreserved word。用反引号引用它:

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

答案 1 :(得分:1)

“订购”是保留字。这是错误的。在反引号中使用订单引用

一词