开发者

PHP & MySQL delete all comments related to an article question

开发者 https://www.devze.com 2023-01-14 12:29 出处:网络
Lets say I have 20 comments that are related to article_id 76 will I have t开发者_开发问答o count all the article ids that have an article_id 76 and then run a foreach loop for all the comments relate

Lets say I have 20 comments that are related to article_id 76 will I have t开发者_开发问答o count all the article ids that have an article_id 76 and then run a foreach loop for all the comments related to article 76 or can I delete all the comments related to that article using a query?

SELECT article_id FROM articles_comments WHERE article_id = 76


DELETE FROM articles_comments WHERE article_id = 76;


DELETE FROM articles_comments WHERE article_id = 76


Just one operation:

 delete from article_comments where article_id = 76


No need for any looping.

This one query will delete all the comments related to article_id 76

DELETE FROM articles_comments 
WHERE article_id = 76;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号