Error :1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL

MySQL,SQL SERVER,ORACLE,数据库出现如下错误: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 '.name

SELECT
    a.*,
    b.NAME  `food.NAME`,
    b.real_price 
FROM
    cart a
    JOIN food b ON a.food_id = b.id 
WHERE
    user_id = 1

这是因为在MySQL数据库中用关键字做字段或者别名时导致的,查询是可以用  `food.NAME` 来括起来,这个  `   符号在键盘左上角Esc下面一个按键,即数字1的左边一个按键,用它把关键字括起来就可以解决这个问题。

猜你喜欢

转载自blog.csdn.net/weixin_42321329/article/details/90261640
今日推荐