How to delete last 10 records in sqlite

后端 未结 3 489
闹比i
闹比i 2021-01-02 21:48

In Sqlite, can I know how to delete last 10 records? I\'ve wrote following coding but seems not working at all.

delete from tb_news where newsid = (SELECT ne         


        
3条回答
  •  醉梦人生
    2021-01-02 22:29

    Did you tried?

    delete from tb_news where newsid IN (SELECT newsid from tb_news order by newsid asc limit 20)
    

    I don't know your table structure, but maybe, it should be DESC instead of ASC. I mean DESC will give you the biggest IDs (and so, the latest).

提交回复
热议问题