I want to select the value from another column if there are no records in the first column (is null). I want something like this:
SELECT (if Column1 IS NULL THEN Column2), Column3, Column4 FROM MyTable
How can I do that in SQLite?
Use the COALESCE function, which returns the first non-null argument:
SELECT COALESCE(Column1, Column2), Column3, Column4
FROM MyTable
In this case, you will get Column1 but if it is NULL, Column2 will be returned instead.
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