我是编码新手。我正在执行此查询:
SELECT order.*, item.*
FROM tbl_orders order
LEFT JOIN tbl_order_items item ON order.id=item.order_id
WHERE order.id=1;
我对这个查询的理解有多正确。但是发生此错误不知道为什么。
错误:
1064-您的SQL语法有误;在第1行的第1行中,检查与您的MySQL服务器版本相对应的手册,以在'order。*,item。* FROM tbl_orders order LEFT JOIN tbl_order_items item.order附近使用正确的语法。
谁能帮我。
这是因为您正在使用mysql的保留字 order
。
您可以将别名更改为其他名称,这样便可以解决问题,如下所示:
SELECT ord.* , item.* FROM tbl_orders ord LEFT JOIN tbl_order_items item on ord.id=item.order_id WHERE ord.id=1;
有关更多信息,请参见以下链接:http : //www.inmotionhosting.com/support/website/database-troubleshooting/error-1064
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句