I have a query as below
SELECT cap_id FROM cap_master WHERE
(cap_type = 'Type1' AND cap_desc = 'CapDesc1')
OR (cap_type = 'Type2' AND cap_desc = 'CapDesc2')
OR (cap_type = 'Type3' AND cap_desc = 'CapDesc3')
OR (cap_type = 'Type4' AND cap_desc = 'CapDesc4')
order by cap_type,cap_desc
This returns multiple rows based on where condition, what i am looking for is like for a condition which do not return any rows, i should have a default value say '0'. As of now i do not get any row for it.
For e.g if 3rd condition (cap_type = 'Type3' AND cap_desc = 'CapDesc3') do not match, i am expecting an output as below:
23
34
0
45
I checked solutions given, like
Return a value if no rows match
Return Default value if no row found -mysql
But seems they don't work on multiple rows getting returned. Any pointers will be greatly appreciated.
Here's a Fiddle to play with.