IFNULL 語句
SELECT IFNULL(value1,value2) AS status; 當value1為null時,返回結果為value2 當value1非null時,返回結果為value1
例1:
SELECT IFNULL('非空','空') AS status; 結果為: 非空 SELECT IFNULL(null,'空') AS status; 結果為: 空
測試結果:
mysql> SELECT IFNULL(null,'空') AS status; +--------+ | status | +--------+ | 空 | +--------+ 1 row in set
mysql> SELECT IFNULL('非空','空') AS status; +--------+ | status | +--------+ | 非空 | +--------+ 1 row in set
mysql>
更多建議: