今天突然遇见过类似的如下问题,经过测试,发现原来null和空值其实还是有区别的,改天在整理下: create table tab ( id integer not null, name char(50), empid char(10), salary char(15) );
insert into tab values(1,'JACK','0001','2000');
insert into tab values(2,'TOM','0002','');
insert into tab values(3,'LUCY','0003','3000');
insert into tab values(4,'JAME','0004','');
insert into tab values(4,'KIM','0005',null);
db2 => select * from tab; select * from tab
ID NAME EMPID SALARY ----------- -------------------------------------------------- ---------- --------------- 1 JACK 0001 2000 2 TOM 0002 3 LUCY 0003 3000 4 JAME 0004 4 KIM 0005 -
5 record(s) selected.
db2 => select * from tab where salary not in ('2000','3000'); select * from tab where salary not in ('2000','3000')
ID NAME EMPID SALARY ----------- -------------------------------------------------- ---------- --------------- 2 TOM 0002 4 JAME 0004
2 record(s) selected.
db2 => select * from tab where salary is null; select * from tab where salary is null
ID NAME EMPID SALARY ----------- -------------------------------------------------- ---------- --------------- 4 KIM 0005 -
添加新评论0 条评论