日期:2014-05-18  浏览次数:20485 次

SQL的删除元组问题
我用SQL2000的时候,建了两个同学数据有birthday是1986-3-21和1987-3-21,用
delete 
from pupil
where birthday<1987-3-21

随便用<或>,都会把数据全删了

------解决方案--------------------
SQL code









create table t(birth datetime)
insert into t select '1986-3-21'
insert into t select '1987-3-21'

select * from t
delete from t
where birth<'1987-3-21'
--(1行受影响)
select * from t
insert into t select '1986-3-21'

delete from t
where birth>'1987-3-21'
--(0行受影响)
select * from t
delete from t
where birth>1987-3-21
--(2行受影响)

select * from t
go
drop table t