When an SQL query returns null, I'm wondering if it's possible to have it return a specific string like "Unknown" instead of null.
I'm currently doing this on the JavaScript side and was wondering if there's a faster way to do this on the server.
Example (I realize the following syntax doesn't exist):
SELECT Customers.Email (RETURN "Unknown" IF NULL)
I imagine it's possible with a CASE? But filling up my query with CASE statements will slow this whole action down rather than speed it up.
You can use coalesce
:
SELECT COALESCE(email, 'Unknown')
FROM customers
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