如何从数据库中删除此查询的结果? 请你帮帮我吗
SELECT v.type
FROM poll_answers
JOIN vote_types v ON poll_answers.vote_id = v.id
JOIN poll_questions q ON q.id = poll_answers.question_id
WHERE q.referendum_id =1
我试图逐个删除它,但是我有外键问题所以我想逐步删除
谢谢
答案 0 :(得分:1)
试试这个:
delete poll_answerpoll_answer,v,q,
FROM poll_answers
JOIN vote_types v ON poll_answers.vote_id = v.id
JOIN poll_questions q ON q.id = poll_answers.question_id
WHERE q.referendum_id =1
修改强>
mysql> delete poll_answers,v,q
-> FROM poll_answers
-> JOIN vote_types v ON poll_answers.vote_id = v.id
-> JOIN poll_questions q ON q.id = poll_answers.question_id
-> WHERE q.referendum_id =1;
Query OK, 0 rows affected (0.00 sec)