我有此sql语句删除一些行:
DELETE
FROM
`user_group_membership` g
INNER JOIN `users` u ON u.user_id = g.user_id
WHERE
u.`user_id` NOT IN (?, ?, ?)
AND g.group_id IN (9, 6)
AND u.`lifetime_supporter` = 0
AND u.supporter_type = 'special'
我收到一个SQL错误“ SQL ERROR SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以在附近使用正确的语法” 'g INNER JOIN users
u在u.user_id = g.user_id上u。user_id
不在((?,?,?“
不能完全确定这里出了什么问题,有人可以给我指点吗?
答案 0 :(得分:1)
您需要指定需要从哪个表中删除记录。 如果要从表user_group_membership中删除,则需要在DELETE命令后指定表,如下所示:
DELETE g
FROM
`user_group_membership` g
INNER JOIN `users` u ON u.user_id = g.user_id
WHERE
u.`user_id` NOT IN (?, ?, ?)
AND g.group_id IN (9, 6)
AND u.`lifetime_supporter` = 0
AND u.supporter_type = 'special'