参考
http://homepage2.nifty.com/sak/w_sak3/doc/sysbrd/mysql_15.htm
■多重判定
・Oracle と同じように case が使えるので非常に強力である。
select key1,
case
when key1 = 'a001' then 'aaa'
when key1 = 'b002' then 'bbb'
when key1 = 'c003' then 'ccc'
else 'xxx'
end c1
from testm
;
select key1,
case key1
when 'a001' then 'aaa'
when 'b002' then 'bbb'
when 'c003' then 'ccc'
else 'xxx'
end c1
from testm
;
■ヌル判定
・coalesce() 関数は、最初の null でないデータを返す。
select coalesce(null, 'abc', 'def');
■ヌル比較
・nullif() 関数は、等しければ null が、等しくなければデータ1 が返る。
次の例は、null が返る。
select nullif('abc', 'abc');
・次の例は、'abc' が返る。
select nullif('abc', 'def') ;