DEV|MUL
xyz|null
null|abc
123|456
我想获取另一个为null的列的值,或者如果两者都具有来自mysql的值,则获取一列专用
答案 0 :(得分:1)
您可以使用IFNULL
SELECT IFNULL(DEV, MUL) as Col FROM myTable -- MySql
SELECT ISNULL(DEV, MUL) as Col FROM myTable -- SQL Server
SELECT NVL(DEV, MUL) as Col FROM myTable -- Oracle
答案 1 :(得分:0)
SELECT IFNULL(DEV, MUL) AS VALUE from table table1;
如果DEV
为not null
,则返回MUL
列值,否则返回{{1}}列值。
答案 2 :(得分:0)
select * from tablename where (columnname is null)
and
select * from tablename where (columnname1 is null) and (columnname2 is null)