从 name IN ( name1 , name2 ) 选项卡中删除 :fails / ok: DELETE FROM tab WHERE id IN ( 1 , 2 )

DELETE FROM tab WHERE name IN ( name1 , name2 ) :fails / ok: DELETE FROM tab WHERE id IN ( 1 , 2 )

删除记录时出错:您的 SQL 语法有误;查看与您的 MariaDB 服务器版本对应的手册,了解在第 1 行的“name2”附近使用的正确**语法 **

  tab:
  __________
  id , name
  __________
   1 , name1
   2 , name2
   3 , name3



  DELETE FROM  tab  WHERE  id   IN ( 1 , 2 )
Record deleted successfully! 

但是错误:

  DELETE FROM  tab  WHERE  name   IN ( name1 , name2 )
Error deleting record: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' name2' at line 1

我想删除name1和name2的数据,不知道id

请帮忙,谢谢

如果这些是字符串值,则需要单引号:

DELETE FROM  tab 
    WHERE name IN ('name1', 'name2')