1

如何从此查询的数据库结果中删除?你们能帮帮我吗

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

我试图一一删除它,但我的外键有问题,所以我想一步一步删除

谢谢你

4

1 回答 1

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)
于 2012-06-07T15:33:42.550 回答