我正在通过 cron 运行 PHP MySQL 命令脚本 (cleanup.php),该脚本从 aggregator_item 表中删除重复的内容和 BS 内容(下表 2)。问题是随着时间的推移, aggregator_category_item 表(下面的表 1)包含太多未引用的行。
理想情况下,表 1 和表 2 应该具有相同的行数。
我需要一个 MySQL 命令 mysql_query(),它将删除 aggregator_category_item 表(表 1)中的所有行,以满足以下条件:
如果在 aggregator_category_item 表(表 2)中找不到 aggregator_category_item 表(表 1)中的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