SQL:不显示包含非数据的列

时间:2015-05-12 07:29:10

标签: sql oracle

我有像这样的SQL输出

t1.column1   t1.column2   t2.column3  t2.column4 ...

#1blabla     blabla       blabla      blabla ..
#2blabla     blabla                   blabla ..

我想编写一个SQL语句,它只显示从column3实际包含数据的行。

在这种情况下,不应显示第2行。

有什么想法吗?

到目前为止我得到了这个:

select *
from
    table1 t1, table2 t2
where
    t1.id = t2.id

2 个答案:

答案 0 :(得分:3)

使用IS NOT NULL

select *
from table1 t1
  JOIN table2 t2 ON t1.id = t2.id
where t2.column3 IS NOT NULL;

用现代JOIN语法重写。

答案 1 :(得分:1)

似乎你可以使用:

select *
from
table1 t1,
table2 t2
where
t1.id = t2.id and t2.colum3 is not null