How do I delete a fixed number of rows with sorting in PostgreSQL?

后端 未结 6 1514
予麋鹿
予麋鹿 2020-11-28 03:27

I\'m trying to port some old MySQL queries to PostgreSQL, but I\'m having trouble with this one:

DELETE FROM logtable ORDER BY timestamp LIMIT 10;

6条回答
  •  囚心锁ツ
    2020-11-28 03:43

    delete from logtable where log_id in (
        select log_id from logtable order by timestamp limit 10);
    

提交回复
热议问题