sql statement is used in, when not in the query, pay attention to conditions in a range of matters dealt with null values

Data in the table emp

 

 

1. When in use, ignore is null, and does not query the data comm to null

select * from emp e where e.comm in (300, 500, null);

2. When not in use, if not in the latter option is not null, only queries from the comm column is not empty column filter will filter out the null data comm

select * from emp e where e.comm not in (300, 500);

3. Use not in time, if not in the back of the options have null, not out of any query data. sql statement itself directly returns false, so when not in use, to ensure that in the case of null conditions do not appear, or unforeseen circumstances may occur.

select * from emp e where e.comm not in (300, 500, null);

 

Guess you like

Origin www.cnblogs.com/rensheng/p/12019782.html