为什么我的MySQL查询不起作用?

时间:2022-08-23 12:11:33

Why doesn't my MySQL query work?

为什么我的MySQL查询不起作用?


Query:

DELETE FROM jos_community_awards a
LEFT JOIN jos_community_users u
ON a.userId = u.userid WHERE a.points > u.points;

Error:

ERROR 1064 (42000): 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 'a LEFT JOIN jos_community_users u ON a.userId = u.userid WHERE a.points > u.poi' at line 1

错误1064(42000):您的SQL语法有错误;检查>对应于您的MySQL服务器版本的手册,以便在'a LEFT JOIN jos_community_users'附近使用正确的语法。在第1行的a.userId = u.userid WHERE a.points> u.poi'

2 个解决方案

#1


It would appear you can't delete from an alias. Or you need to specify the entire row so a.* I think you need to specify the entire row with .* either on the table name or the alias.

看起来你无法从别名中删除。或者你需要指定整行,以便。*我认为你需要在表名或别名上用。*指定整行。

#2


DELETE queries with joins are bit tricky. Adding the table name after the DELETE keyword should help if I remember correctly:

带连接的DELETE查询有点棘手。如果我没记错的话,在DELETE关键字后添加表名应该会有所帮助:

DELETE jos_community_awards FROM jos_community_awards ...

#1


It would appear you can't delete from an alias. Or you need to specify the entire row so a.* I think you need to specify the entire row with .* either on the table name or the alias.

看起来你无法从别名中删除。或者你需要指定整行,以便。*我认为你需要在表名或别名上用。*指定整行。

#2


DELETE queries with joins are bit tricky. Adding the table name after the DELETE keyword should help if I remember correctly:

带连接的DELETE查询有点棘手。如果我没记错的话,在DELETE关键字后添加表名应该会有所帮助:

DELETE jos_community_awards FROM jos_community_awards ...