No, you need to apply IFNULL to each column individually.

However, if you had a slightly different requirement, that is, to show the first non-null column from a number of columns, and show a default if they are all null, you could use the COALESCE function like so:

select coalesce(col1,col2,col3,0)
from tbl

The problem with this is that it will return a single column in the result, and not multiple columns corresponding to col1, col2 and col3. Therefore, as long as you want to have multiple columns in your result set, you need to do the null handling on a per-column basis.

Answer from shree.pat18 on Stack Overflow
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › language-elements › nullif-transact-sql
NULLIF (Transact-SQL) - SQL Server | Microsoft Learn
Applies to: SQL Server Azure SQL ... in Microsoft Fabric SQL database in Microsoft Fabric · Returns a null value if the two specified expressions are equal....
🌐
W3Schools
w3schools.com › sql › func_sqlserver_nullif.asp
SQL Server NULLIF() Function
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Certificate SQL Training ... The NULLIF() function returns NULL if two expressions are equal, otherwise it returns the first expression.
🌐
Medium
medium.com › @etimfonime › can-you-use-nullif-for-multiple-criteria-in-sql-58ab1ec801db
Can You Use NULLIF() Function for Multiple Criteria in SQL? | by Ime Eti-mfon | Medium
July 11, 2024 - SELECT CASE WHEN column1 = 'criteria1' THEN NULL WHEN column1 = 'criteria2' THEN NULL WHEN column1 = 'criteria3' THEN NULL ELSE column1 END AS result FROM table; You can also combine NULLIF() with COALESCE() to handle multiple nullifying conditions:
🌐
SQL Server Tutorial
sqlservertutorial.net › home › sql server basics › sql server nullif
SQL Server NULLIF
July 10, 2020 - SELECT lead_id, first_name, last_name, phone, email FROM sales.leads WHERE phone IS NULL; Code language: SQL (Structured Query Language) (sql) ... The output missed one row which has the empty string in the phone column. To fix this you can use the NULLIF expression:
🌐
Hightouch
hightouch.com › sql-dictionary › sql-nullif
SQL NULLIF - Syntax, Use Cases, and Examples | Hightouch
December 29, 2023 - The syntax for the SQL NULLIF function is as follows: ... expression2: The second expression or value you want to compare to expression1. If expression1 is equal to expression2, NULL is returned; otherwise, expression1 is returned. expression1: The first expression or value you want to compare. expression2: The second expression or value you want to compare to expression1. Suppose we have a table named "products" with columns "product_id," "product_name," and "discontinued."
🌐
PopSQL
popsql.com › learn-sql › postgresql › how-to-use-nullif-in-postgresql
PostgreSQL: nullif() Function Usage - PopSQL
The nullif() function returns a null value, if a the value of the field/column defined by the first parameter equals that of the second. Otherwise, it will return the original value.
Find elsewhere
🌐
DB Vis
dbvis.com › thetable › postgresql-nullif-conditional-logic-made-easier
PostgreSQL NULLIF: Conditional Logic Made Easier
September 11, 2024 - Let’s see NULLIF in action in a sample PostgreSQL query: ... When the age column contains the value 0, the NULLIF function will replace it with a NULL in the result set.
🌐
C# Corner
c-sharpcorner.com › blogs › sql-server-isnull-with-multi-column-names
SQL Server ISNULL() With Multi Column Names
November 26, 2018 - See the following example of using ... function The IsNull function can check only if one value is null. It cannot check null for multiple values....
🌐
Snowflake Documentation
docs.snowflake.com › en › sql-reference › functions › nullif
NULLIF | Snowflake Documentation
SELECT a, b, NULLIF(a,b) FROM i; --------+--------+-------------+ a | b | nullif(a,b) | --------+--------+-------------+ 0 | 0 | [NULL] | 0 | 1 | 0 | 0 | [NULL] | 0 | 1 | 0 | 1 | 1 | 1 | [NULL] | 1 | [NULL] | 1 | [NULL] | 0 | [NULL] | [NULL] | 1 | [NULL] | [NULL] | [NULL] | [NULL] | --------+--------+-------------+
🌐
Sqlteam
weblogs.sqlteam.com › jeffs › 2007 › 09 › 27 › sql-nullif-function
A handy but little-known SQL function: NULLIF() | Jeff Smith Blog
October 6, 2010 - A handy but little-known SQL function: NULLIF() Is it a String Literal or an Alias? Passing an Array or Table Parameter to a Stored Procedure · SELECT * FROM TABLE -- except for these columns · In SQL, it's a Case Expression, *not* a Case Statement ·
🌐
W3Schools
w3schools.com › sql › func_mysql_nullif.asp
MySQL NULLIF() Function
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Certificate SQL Training ... The NULLIF() function compares two expressions and returns NULL if they are equal.
🌐
EDUCBA
educba.com › home › data science › data science tutorials › sql tutorial › sql nullif()
SQL NULLIF() | A Quick Glance to SQL NULLIF() with Examples
March 10, 2023 - NULLIF() is a comparison function in standard query language (SQL) that takes two expressions as arguments and returns NULL if the two expressions are equal. The data type of the NULL value returned is the same as the first expression.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
ByteScout
bytescout.com › blog › coalesce-nullif-isnull-functions-in-sql.html
COALESCE, NULLIF, and ISNULL function in SQL - ByteScout
June 21, 2023 - COALESCE is a function in SQL that ... null, COALESCE will return null. It is commonly used to replace null values with a default value or to combine two columns, choosing non-null values first....
🌐
DotFactory
dofactory.com › sql › nullif
SQL NULLIF Function
SELECT NULLIF('SQL', 'NoSQL') AS ... SELECT * FROM Customer WHERE NULLIF(City,'') IS NULL · Syntax for the NULLIF function. NULLIF(value1, value2) value1 -- any value or column name....
🌐
SQL Tutorial
sqltutorial.org › home › sql nullif function
SQL NULLIF Function
February 8, 2025 - Summary: in this tutorial, you will learn how to use the SQL NULLIF function to compare two values and return NULL if they are equal.