从子查询中删除

时间:2014-07-27 13:15:57

标签: mysql

我的查询无效:

DELETE FROM (
     SELECT *
     FROM `chat`
     ORDER BY `message_id` ASC
     LIMIT 50
) AS deleted

2 个答案:

答案 0 :(得分:3)

不要使用子查询:

DELETE c FROM `chat` c
    ORDER BY `message_id` ASC
    LIMIT $NUM;

在MySQL中,DELETE支持order bylimit

答案 1 :(得分:2)

$sql3 = "DELETE FROM chat ORDER BY message_id LIMIT ".$NUM;