0
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'

4

2 回答 2

1

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 ...
于 2011-11-04T12:57:05.363 回答
0

Another option would be: IFNULL

于 2011-11-04T13:00:04.013 回答