例如: 我只想删除只包含科目只为化学的编号,001因为有语文所有不能删除,
只能删除002,这个语句该怎么写啊?请大神给看看
编号,科目
001 化学
001 语文
002 化学
003 数学
delete * from table where 编号 not in (select 编号 from table where 科目 <> "化学")
delete from table where kemu='化学';
如果表数据比较多,建议在科目字段添加索引。
我试了下好像都有错误那,不过还是谢谢2位热心朋友
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table where 编号 not in (select 编号 from table where 科目 <> "化学")' at line 1
不好意思,我语法问题,2楼的可以使用