我正在通过cron运行PHP MySQL命令脚本(cleanup.php),删除了aggregator_item表中的副本和BS内容(下面的表2)。问题是,随着时间的推移,aggregator_category_item表(下面的表1)包含太多未引用的行。
理想情况下,表1和表2应具有相同行数。
我需要一个MySQL命令mysql_query(),它会删除aggregator_category_item表(表1)中的所有行,以了解以下情况:
如果在aggregator_item表(表2)中找到了aggregate_category_item表(表1)中的 idd 号 NOT ,则从aggregator_category_item表中删除这些未引用的行(表格1)。我想将这个MySQL delete命令添加到我当前的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
答案 0 :(得分:2)
delete from aggregator_category_item
where iid not in (select iid from aggregator_item)