0

我正在尝试运行一个查询,该查询将删除数据库中除 9 个最新条目之外的所有条目。uid 为 id_lv,表名为 last_viewed

mysql_query('DELETE FROM last_viewed WHERE id_lv NOT IN (SELECT id_lv FROM last_viewed ORDER BY id_lv, desc LIMIT 0, 9');

我完全没有错误,但没有任何反应。

谢谢

4

2 回答 2

1
mysql_query('DELETE FROM last_viewed 
               WHERE id_lv NOT IN 
              (SELECT id_lv FROM last_viewed 
               ORDER BY id_lv desc LIMIT 0, 9)');
于 2012-09-25T23:36:15.127 回答
0

包围错误。您在子查询中缺少一个结束)符,并且 DESC 关键字之前不应该有逗号。

mysql_query('DELETE FROM last_viewed
             WHERE id_lv NOT IN (
                 SELECT id_lv
                 FROM last_viewed
                 ORDER BY id_lv desc
                 LIMIT 0, 9)');
于 2012-09-25T23:41:48.917 回答