我想删除表participant_vote中id与另一个表行的id匹配的所有记录。
这可以在一个查询中完成吗?
这是我现在的查询,它返回我的子选择包含多行的错误
DELETE FROM
participant_vote
WHERE id =(SELECT id FROMvote
WHEREfacebookid
=:facebookid)
答案 0 :(得分:2)
是。使用IN
运算符代替=
运算符。
DELETE FROM participant_vote
WHERE id IN (
SELECT id
FROM vote
WHERE facebookid = :facebookid
)
答案 1 :(得分:2)
DELETE FROM participant_vote WHERE id IN (SELECT id FROM vote WHERE facebookid = :facebookid)
IN
是诀窍。我的感觉是,搜索信息也会提供答案。