DEV|MUL
xyz|null
null|abc
123|456
我想获取另一列为空的列的值,或者如果两者都有来自mysql的值,则专门获取一列
您可以使用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
SELECT IFNULL(DEV, MUL) AS VALUE from table table1;
DEV
如果它是返回列值,这将返回not null
列MUL
值。
select * from tablename where (columnname is null)
and
select * from tablename where (columnname1 is null) and (columnname2 is null)