有如下表
id name 1 a
2 aa
3 aaa
4 aaaa
5 aaaaa比如我想删掉 name长度大于2的 ,使用如下语句为什么都给删了??delete from table1 where exists
(
select 1 from table1 where datalengh(name) >2
)感觉我对exists理解有问题。
id name 1 a
2 aa
3 aaa
4 aaaa
5 aaaaa比如我想删掉 name长度大于2的 ,使用如下语句为什么都给删了??delete from table1 where exists
(
select 1 from table1 where datalengh(name) >2
)感觉我对exists理解有问题。
EXISTS是为true的所以都删掉了。
#1.select 1 from table1 where datalengh(name) > 2 ,返回的值为1
#2.delete from table1 where exists(1) = delete from table1
(
select 1 where datalengh(name) >2
)
id name
1 a
2 aa*/DELETE FROM TB WHERE EXISTS(SELECT 1 FROM TB WHERE LEN(NAME)>2)--Exists 中条件成立(表中Name列含有长度大于2的数据)则,表中数据均被删除了