SELECT 'id' FROM `table` WHERE `id` =
(select min(`id`) FROM `table` where
`id` < 1 and `ids` = 1)
id ids
1 1
2 1
5 1
6 1
结果:
id = ''
我需要更改id=''
为id='n/a'
If the query return a null result you can use COALESCE so :
SELECT COALESCE('id','N/A') FROM ...
OR if the return result is an empty string you can do :
SELECT CASE WHEN id = '' THEN 'N/A' ELSE id END FROM ...
Another option would be: IFNULL