sql删除表中某些行数据

2024-11-30 10:54:35
推荐回答(5个)
回答(1):

删除除白沙外的所有行数据:
delete from 表名 where 字段名 <>'白沙'

删除除白沙、北京外的数据:
delete from 表名 where 字段名 not in('白沙','北京')
或者
delete from 表名 where 字段名 <>'白沙' and 字段名<>'北京'

回答(2):

删除除白沙外
delete from test where address <> '白沙'
删除除白沙,北京外
delete from test where address <> '白沙' or address <> '北京'
或者
delete from test where address not in ('白沙','北京')

回答(3):

表名test 白沙那一列为address
delete from test where address <>'白沙'

补:
那就在后面再加一个条件
delete from test where address <>'白沙' and address<>'北京'

回答(4):

delete from 表名 where 字段名 <>'白沙' and 字段名<>'北京'

回答(5):

delete test where address<>'白沙' or address<>'北京'