MySQL IFNULL() function usage in SELECT queries

Joshua Otwell
4 min readJul 29, 2020

We all know as SQL professionals that the NULL marker is a special case. Oftentimes, you have NULL‘s stored in your tables, and that’s fine. Suppose you want to present an alternative value in query results where some of the columns have NULL? This is a perfect opportunity (but not the only) to use the IFNULL() function. I find IFNULL() quite useful when exporting query results to a CSV file or other type of flat file, providing something more meaningful than the NULL word itself. However, you only have one substitute for the NULL value when using IFNULL(), so keep that in…

Joshua Otwell

SQL, PHP, CodeIgniter, and WordPress. Growing through Technical Writing and Blogging. Sign-up for my free developer newsletter here: openlamptech.substack.com