I want to fetch records for column value not equal to null and column value not equal to default value. I know that we can use
SELECT * FROM table WHERE column_name is NOT NULL AND column_name != 'some_default_value';
but what if some one in future changes this some_default_value in table? Is there a flexible solution?
You can use the DEFAULT
function:
SELECT *
FROM table
WHERE IFNULL(column_name, DEFAULT(column_name)) <> DEFAULT(column_name);
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