我有疑问:
SELECT *
FROM `phpbb_posts` AS a
JOIN phpbb_posts_text AS b ON a.post_id = b.post_id
WHERE a.poster_id =5413
它给了我X行数,我想要一个将删除所有这些行的查询(我不需要先选择那只是JOIN的一个例子。
任何帮助?
答案 0 :(得分:4)
这很简单。
DELETE a, b
FROM `phpbb_posts` AS a
JOIN phpbb_posts_text AS b ON a.post_id = b.post_id
WHERE a.poster_id =5413
答案 1 :(得分:0)
您可以单独删除每个表
DELETE b
FROM phpbb_posts_text AS b
INNER JOIN `phpbb_posts` AS a
ON
a.post_id = b.post_id
AND a.poster_id =5413
DELETE a
FROM `phpbb_posts` AS a
WHERE a.poster_id =5413
第二个可以写成
DELETE `phpbb_posts`
WHERE poster_id =5413