gpt4 book ai didi

mysql - 如何删除 mysql 数据库中表中的所有行,其中一列的值 = 0?

转载 作者:行者123 更新时间:2023-12-01 00:05:05 25 4
gpt4 key购买 nike

基本上,它是这样的:

该表名为 phpbb_posts

列名是post_approved

我想运行一个查询,删除 phpbb_posts 表中 post_approved 值为 0 的所有行(所有行都包含 1 或 0 值列 post_approved)

在运行查询之前,我想确保我正在运行正确的查询。

DELETE FROM phpbb_posts
WHERE EXISTS(
SELECT *
FROM phpbb_posts
WHERE (post_approved = 0)
)

请告诉我这段代码是否正确;或者如果有误,请告诉我正确的代码。



代码已修复(谢谢!):

DELETE FROM phpbb_posts WHERE post_approved = 0

结果:

35743 rows deleted. ( Query took 1.3562 sec )

P.S. FOR THOSE WONDERING, THIS REMOVES ALL SPAM POSTS FROM PHPBB INONE FELL SWOOP! (assuming you don't have any valid posts you want toapprove). Instead of going through moderator and "disapproving" for50,000 pages, you can do this! :) :)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

关于mysql - 如何删除 mysql 数据库中表中的所有行,其中一列的值 = 0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16378167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com