在mysql中删除null

时间:2017-11-28 23:48:28

标签: mysql mysql-workbench

[ASK]

如何在mysql中删除null?

CREATE VIEW konsumenlist AS select 
(select nama_konsumen  where jenis_kelamin_konsumen="laki-laki" ) as Laki_laki,
(select nama_konsumen  where jenis_kelamin_konsumen="perempuan" ) as Perempuan  
from konsumen;
select * from konsumenlist;

1 个答案:

答案 0 :(得分:0)

如果我理解你,我认为这很容易。您需要使用IFNULLCOALESCE

CREATE VIEW konsumenlist AS select 
IFNULL((select nama_konsumen  where jenis_kelamin_konsumen="laki-laki" ),'---') as Laki_laki,
COALESCE((select nama_konsumen  where jenis_kelamin_konsumen="perempuan" ),'---') as Perempuan  
from konsumen;