[英]How can I delete all rows within a table in a mysql database, which value = 0 for one of the columns?
So basically, it's like this: 所以基本上,是这样的:
The table is called phpbb_posts
该表称为
phpbb_posts
The column name is post_approved
列名是
post_approved
I want to run a query which deletes all rows in phpbb_posts
table in which the post_approved
value is 0 (All rows contain either a 1 or a 0 value for the column post_approved
) 我想运行它删除在所有行的查询
phpbb_posts
表,其中post_approved
值为0(所有的行包含一个1或该列的0值post_approved
)
I wanted to make sure I am running the correct query, before running it. 我想确保在运行正确的查询之前,先运行它。
DELETE FROM phpbb_posts
WHERE EXISTS(
SELECT *
FROM phpbb_posts
WHERE (post_approved = 0)
)
Please tell me if this code is correct; 请告诉我该代码是否正确; or if it is wrong, please tell me the correct code.
否则,请告诉我正确的代码。
CODE FIXED (thanks!): 固定代码(谢谢!):
DELETE FROM phpbb_posts WHERE post_approved = 0
RESULT: 结果:
35743 rows deleted. ( Query took 1.3562 sec )
PS FOR THOSE WONDERING, THIS REMOVES ALL SPAM POSTS FROM PHPBB IN ONE FELL SWOOP!
PS真是太神奇了,它一次删除了PHPBB的所有垃圾邮件! (assuming you don't have any valid posts you want to approve).
(假设您没有要批准的任何有效信息)。 Instead of going through moderator and "disapproving" for 50,000 pages, you can do this!
您可以执行此操作,而不必经过主持人并“拒登” 50,000个页面。 :) :) and yes I checked in the moderator queue and all the spam posts i never approved are gone!
:) :)是的,我检查了主持人队列,我从未批准的所有垃圾邮件都消失了! YAY!
好极了!
做就是了
DELETE FROM phpbb_posts WHERE post_approved = 0
Just use 只需使用
DELETE FROM phpbb_posts
WHERE post_approved = 0
that should do it fine. 那应该做得很好。
I would think just: 我会认为:
DELETE FROM phpbb_posts
WHERE post_approved = 0;
Would suffice 足够了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.