Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL IFNULL question

Tags:

mysql

ifnull

I have a query which contains a subquery which is something like this

IFNULL((SELECT id FROM mytable WHERE id = 1), 'No')

It works OK, but I would like to return the string 'Yes' on success rather than the actual id of the row.

Is there any way to override the value it returns?

Thanks.

like image 744
Dan Avatar asked Jan 27 '10 12:01

Dan


1 Answers

IFNULL((SELECT 'Yes' FROM mytable WHERE id = 1), 'No')
like image 166
Jan Hančič Avatar answered Sep 20 '22 13:09

Jan Hančič