我的查询无效:
DELETE FROM (
SELECT *
FROM `chat`
ORDER BY `message_id` ASC
LIMIT 50
) AS deleted
答案 0 :(得分:3)
不要使用子查询:
DELETE c FROM `chat` c
ORDER BY `message_id` ASC
LIMIT $NUM;
在MySQL中,DELETE
支持order by
和limit
。
答案 1 :(得分:2)
$sql3 = "DELETE FROM chat ORDER BY message_id LIMIT ".$NUM;