0
How would I write a SQL query in a MySQL environment where I explicitly replace all NULL values returned my query with the word NULL?
0
How would I write a SQL query in a MySQL environment where I explicitly replace all NULL values returned my query with the word NULL?
1
SELECT COALESCE( yourNullValue , 'NULL') FROM whatever
COALESCE(value,...)
Returns the first non-NULL value in the list, or NULL if there are no non-NULL values.
The return type of COALESCE() is the aggregated type of the argument types.
Source: https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#function_coalesce
Functional, but please include a note indicating how much of a bad idea this is. – Attie – 2018-10-02T11:38:33.113
3
Or, don't... http://www.bbc.com/future/story/20160325-the-names-that-break-computer-systems
– Arjan – 2017-07-18T21:02:44.113This is a terrible idea... a zero-length string might be somewhat acceptable, but the correct solution is to handle NULLs properly in your application. – Attie – 2018-10-02T11:38:11.710