I have a query where I match a column. The value to be matched may be null or not null (some value exists). The problem arises when the matching takes place. In case value is present the matching like
table.column = somevalue
works fine, but in case the value is null, then the matching needs to be done as
table.column is null
Is there some way that I can choose the condition being used in the WHERE clause based on the value?
Thanks in advance
What about ORing your WHERE
clause?
SELECT
*
FROM table
WHERE ((table.column = 123) AND table.column IS NOT NULL))
OR (table.column IS NULL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With