You should use IS NOT NULL. (The comparison operators = and <> both give UNKNOWN with NULL on either side of the expression.)

CopySELECT * 
FROM table 
WHERE YourColumn IS NOT NULL;

Just for completeness I'll mention that in MySQL you can also negate the null safe equality operator but this is not standard SQL.

CopySELECT *
FROM table 
WHERE NOT (YourColumn <=> NULL);

Edited to reflect comments. It sounds like your table may not be in first normal form in which case changing the structure may make your task easier. A couple of other ways of doing it though...

CopySELECT val1 AS val
FROM  your_table
WHERE val1 IS NOT NULL
UNION ALL
SELECT val2 
FROM  your_table
WHERE val2 IS NOT NULL
/*And so on for all your columns*/

The disadvantage of the above is that it scans the table multiple times once for each column. That may possibly be avoided by the below but I haven't tested this in MySQL.

CopySELECT CASE idx
         WHEN 1 THEN val1
         WHEN 2 THEN val2
       END AS val
FROM   your_table
        /*CROSS JOIN*/
       JOIN (SELECT 1 AS idx
                   UNION ALL
                   SELECT 2) t
HAVING val IS NOT NULL  /*Can reference alias in Having in MySQL*/
Answer from Martin Smith on Stack Overflow
🌐
W3Schools
w3schools.com › sql › sql_null_values.asp
SQL NULL Values - IS NULL and IS NOT NULL
SELECT column_names FROM table_name WHERE column_name IS NOT NULL; Below is a selection from the Customers table used in the examples: The IS NULL operator is used to test for empty values (NULL values). The following SQL lists all customers with a NULL value in the "Address" field:
🌐
Hightouch
hightouch.com › sql-dictionary › sql-is-not-null
SQL IS NOT NULL - Syntax, Use Cases, and Examples | Hightouch
December 29, 2023 - You would use the SQL IS NOT NULL operator when you need to filter data from a table based on whether a column's value is not NULL. This is useful when you want to retrieve records with data present in a specific column or attribute, ensuring ...
Discussions

sql - MySQL SELECT only not null values - Stack Overflow
This query select last not null value for each column. ... CopySELECT DISTINCT ( SELECT title FROM test WHERE title IS NOT NULL ORDER BY id DESC LIMIT 1 ) title, ( SELECT body FROM test WHERE body IS NOT NULL ORDER BY id DESC LIMIT 1 ) body FROM test · I hope help you. ... Save this answer. ... Show activity on this post. ... Save this answer. ... Show activity on this post. Yes use NOT NULL in ... More on stackoverflow.com
🌐 stackoverflow.com
Need some knowledge on NULL and NOT NULL
a null is used for multiple purposes -- for example, not known, not applicable, etc. theoreticians take great joy in debating which uses are valid, and whether they can be substituted by some non-null placeholder suffice to say, a null is used when you don't know what value should go there if you don't want that situation to arise, just make the column NOT NULL and you'll never be able to not insert an actual value More on reddit.com
🌐 r/SQL
33
14
December 22, 2021
Merging two columns, each with null values in different rows, to create a new column with the least amount of null values.
Conditional column. If A is not null, column A else B More on reddit.com
🌐 r/PowerBI
3
3
August 29, 2019
insert into if not null
Why not simply exclude those rows from the select: insert into table2(...) select ... from table1 where some_column is not null; This would insert those rows that do not violate the NOT NULL constraint. If you do not want to insert anything if at least one NULL value is found, you could use: insert into table2 (...) select ... from table1 where not exists (select * from table1 where some_column is null); More on reddit.com
🌐 r/SQL
5
1
July 4, 2019
🌐
Mimo
mimo.org › glossary › sql › is-not-null
SQL IS NOT NULL Condition: Syntax, Usage, and Examples
... -- Wrong SELECT * FROM products WHERE price != NULL; -- Right SELECT * FROM products WHERE price IS NOT NULL; Use IS NOT NULL whenever you're testing the existence of a value—not just its specific content. Some SQL tutorials call this the IS NOT NULL operator.
Top answer
1 of 12
542

You should use IS NOT NULL. (The comparison operators = and <> both give UNKNOWN with NULL on either side of the expression.)

CopySELECT * 
FROM table 
WHERE YourColumn IS NOT NULL;

Just for completeness I'll mention that in MySQL you can also negate the null safe equality operator but this is not standard SQL.

CopySELECT *
FROM table 
WHERE NOT (YourColumn <=> NULL);

Edited to reflect comments. It sounds like your table may not be in first normal form in which case changing the structure may make your task easier. A couple of other ways of doing it though...

CopySELECT val1 AS val
FROM  your_table
WHERE val1 IS NOT NULL
UNION ALL
SELECT val2 
FROM  your_table
WHERE val2 IS NOT NULL
/*And so on for all your columns*/

The disadvantage of the above is that it scans the table multiple times once for each column. That may possibly be avoided by the below but I haven't tested this in MySQL.

CopySELECT CASE idx
         WHEN 1 THEN val1
         WHEN 2 THEN val2
       END AS val
FROM   your_table
        /*CROSS JOIN*/
       JOIN (SELECT 1 AS idx
                   UNION ALL
                   SELECT 2) t
HAVING val IS NOT NULL  /*Can reference alias in Having in MySQL*/
2 of 12
25

You can filter out rows that contain a NULL value in a specific column:

CopySELECT col1, col2, ..., coln
FROM yourtable
WHERE somecolumn IS NOT NULL

If you want to filter out rows that contain a null in any column then try this:

CopySELECT col1, col2, ..., coln
FROM yourtable
WHERE col1 IS NOT NULL
AND col2 IS NOT NULL
-- ...
AND coln IS NOT NULL

Update: Based on your comments, perhaps you want this?

CopySELECT * FROM
(
    SELECT col1 AS col FROM yourtable
    UNION
    SELECT col2 AS col FROM yourtable
    UNION
    -- ...
    UNION
    SELECT coln AS col FROM yourtable
) T1
WHERE col IS NOT NULL

And I agre with Martin that if you need to do this then you should probably change your database design.

🌐
W3Schools
w3schools.com › sql › sql_notnull.asp
SQL NOT NULL Constraint
To define a NOT NULL constraint when creating a table, add NOT NULL after the data type of the column name. The following SQL creates a "Persons" table, and ensures that the "ID", "LastName", and "FirstName" columns cannot accept NULL values:
🌐
TechOnTheNet
techonthenet.com › sql_server › is_not_null.php
SQL Server: IS NOT NULL Condition
INSERT INTO contacts (contact_id, last_name, first_name) SELECT employee_id, last_name, first_name FROM employees WHERE last_name IS NOT NULL; This SQL Server IS NOT NULL example will insert records into the contacts table where the last_name does not contain a null value in the employees table.
🌐
DB Vis
dbvis.com › thetable › sql-is-not-null-condition-definitive-guide
SQL IS NOT NULL Condition: Definitive Guide
August 13, 2025 - In SQL, <> NULL and != NULL are equivalent, but neither works as expected because NULL represents an unknown value. Any comparison with NULL—even NULL <> NULL—returns “unknown,” not “true” or “false.” To correctly check if a ...
Find elsewhere
🌐
Oracle
docs.oracle.com › en › database › other-databases › nosql-database › 25.3 › sqlreferencefornosql › is-null-and-is-not-null-operators.html
IS NULL and IS NOT NULL Operators
February 6, 2026 - SELECT ticketNo,fullname FROM BaggageInfo bag WHERE EXISTS bag.bagInfo.tagNum [$element IS NOT NULL] Explanation: In the airline baggage tracking application, there is a unique tag number associated with every checked bag carried by the passenger. In this query, you fetch the details of passengers who have a tag number, which means the tagNum field in the bagInfo table is not null.
🌐
Programiz
programiz.com › sql › is-null-not-null
SQL IS NULL and IS NOT NULL (With Examples)
In SQL, the IS NOT NULL condition is used to select rows if the specified field is NOT NULL. It has the following syntax: SELECT column1, column2, ... FROM table WHERE column_name IS NOT NULL; ... Here, the above SQL query retrieves all the rows from the Employee table where the value of the ...
🌐
Hightouch
hightouch.com › sql-dictionary › sql-not-null
SQL NOT NULL - Syntax, Use Cases, and Examples | Hightouch
December 29, 2023 - Here's an example SQL query that ... "first_name" columns: CREATE TABLE employees ( employee_id INT NOT NULL, first_name VARCHAR(50) NOT NULL, last_name VARCHAR(50), date_of_birth DATE, -- Other columns );...
🌐
MSSQLTips
mssqltips.com › home › sql where is not null examples
SQL WHERE IS NOT NULL Examples
March 13, 2023 - The following query is an example ... AND hireDate < '2013'; ... The SQL WHERE IS NOT NULL constraint can be used with the UPDATE statement to ensure that only records that are not NULL are updated....
🌐
Reddit
reddit.com › r/sql › need some knowledge on null and not null
r/SQL on Reddit: Need some knowledge on NULL and NOT NULL
December 22, 2021 -
  • Where and why exactly a null is used?

  • What is exactly null and not null? To my understanding Not null we use when its mandatory to insert some value in that field, also when we give check constraint so by default the column will be not null right?

  • By adding new column through alter method default values are null, so how would I be able to insert values in it and is it right to give not null constraint to that new column while adding through alter method, basically when null and when not null to be used?...

god this is so confusing please help me, ik im asking alot but im really confused

🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-is-not-null-operator
SQL IS NOT NULL Operator - GeeksforGeeks
July 23, 2025 - SELECT * FROM geeksforgeeks WHERE courses IS NOT NULL; ... This query filters rows where the COURSES column contains values other than NULL. Only rows with non-NULL values in the COURSES column will be displayed.
🌐
TechOnTheNet
techonthenet.com › sql › is_not_null.php
SQL: IS NOT NULL Condition
This SQL tutorial explains how to use the SQL IS NOT NULL condition with syntax and examples. The IS NOT NULL condition is used in SQL to test for a non-NULL value. It returns TRUE if a non-NULL value is found, otherwise it returns FALSE.
🌐
Tutorialspoint
tutorialspoint.com › sql › sql-is-not-null.htm
SQL - IS NOT NULL Operator
The IS NOT NULL operator in SQL is used to check whether a column contains a non-null value. In SQL, NULL represents missing, undefined, or unknown data, it is not the same as zero, an empty string, or a space.
🌐
W3Schools
w3schools.com › mysql › mysql_null_values.asp
MySQL NULL Values - IS NULL and IS NOT NULL
SELECT column_names FROM table_name WHERE column_name IS NOT NULL; Below is a selection from the "Customers" table in the Northwind sample database: The IS NULL operator is used to test for empty values (NULL values). The following SQL lists all customers with a NULL value in the "Address" field:
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-not-null-constraint
SQL NOT NULL Constraint - GeeksforGeeks
February 10, 2026 - In SQL, NOT NULL constraint in SQL ensures a column must always contain a value and cannot be left empty.
🌐
DotFactory
dofactory.com › sql › where-isnull
SQL IS NULL | IS NOT NULL
A WHERE IS NULL clause returns rows with columns that have NULL values. WHERE IS NOT NULL returns rows with column values that are not NULL.
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › queries › is-null-transact-sql
IS NULL (Transact-SQL) - SQL Server | Microsoft Learn
... If the value of expression is NULL, IS NULL returns TRUE; otherwise, it returns FALSE. If the value of expression is NULL, IS NOT NULL returns FALSE; otherwise, it returns TRUE.
🌐
W3Schools
w3schools.com › sql › sql_ref_not_null.asp
SQL NOT NULL
String Functions: Asc Chr Concat ... SQL Study Plan SQL Bootcamp SQL Training ... The NOT NULL constraint enforces a column to not accept NULL values, which means that you cannot insert or update a record without adding a value ...