Delete many rows from a table using id in Mysql

前端 未结 9 1882
遇见更好的自我
遇见更好的自我 2021-01-30 15:38

I am a Linux admin with only basic knowledge in Mysql Queries

I want to delete many table entries which are ip address from my table using id,

相关标签:
9条回答
  • 2021-01-30 16:32
    DELETE FROM table_name WHERE id BETWEEN 1 AND 256;
    

    Try This.

    0 讨论(0)
  • 2021-01-30 16:34

    Others have suggested IN, this is fine. You can also use a range:

    DELETE from tablename where id<254 and id>3;
    

    If the ids to delete are contiguous.

    0 讨论(0)
  • 2021-01-30 16:35

    Use IN Clause

       DELETE from tablename where id IN (1,2);
    

    OR you can merge the use of BETWEEN and NOT IN to decrease the numbers you have to mention.

    DELETE from tablename 
    where (id BETWEEN 1 AND 255) 
    AND (id NOT IN (254));
    
    0 讨论(0)
提交回复
热议问题