gpt4 book ai didi

mysql - 需要从 Drupal MySQL 数据库中删除未引用的行

转载 作者:行者123 更新时间:2023-11-29 08:45:24 24 4
gpt4 key购买 nike

我正在通过 cron 运行 PHP MySQL 命令脚本 (cleanup.php),该脚本从 aggregator_item 表(下面的表 2)中删除重复内容和 BS 内容。问题是随着时间的推移,aggregator_category_item 表(下面的表 1)包含太多未引用的行。

理想情况下,表 1 和表 2 应具有相同行数。

我需要一个 MySQL 命令 mysql_query(),它将删除 aggregator_category_item 表(表 1)中的所有行,以满足以下条件:

如果在 aggregator_category_item 表(表 1)中没有找到 aggregator_category_item 表(表 2)中的 idd 编号,则从 aggregator_category_item 表中删除这些未引用的行(表格1)。我想将此 MySQL 删除命令添加到我当前的 MySQL 命令 cron 脚本中。

下面是 Drupal 数据库中的以下两个表:

Table 1: aggregator_category_item (145,000 rows)
-----------------------------------------------
iid cid
6644403 2


Table 2: aggregator_item (8700 rows)
------------------------------------
iid fid title link author description timestamp
6644403 25 hello http://... hello there 1348243145

最佳答案

delete from aggregator_category_item
where iid not in (select iid from aggregator_item)

关于mysql - 需要从 Drupal MySQL 数据库中删除未引用的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12644281/

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