要显示表的所有记录?

时间:2014-03-10 07:58:30

标签: sql oracle

显示table1的所有记录,除了A包含2以及B包含5

Table1
------

A          B
-         
8          5

2          9

null       4

2          5

select * from table1 where a not in 2 and b not in 5;

它不起作用,它将显示为0行选择

1 个答案:

答案 0 :(得分:3)

试试这个:

SELECT * FROM Table1
WHERE (a is null or a != 2) and (b is null or b != 5)

修改

Sql Fiddle, many thanks to Nagaraj S