Sql-server – Microsoft SQL Joins and Where Clause

sql serversql-server-2012t-sql

I am sure a very simple question for people out there but my brain has shutdown.

I have joined two tables with a left join which has worked as hoped as I do need to bring back the NULLs in one of the tables as some of the rows will not have cosponsoring matches.

I need to put a WHERE clause on one of the columns that 'Could' be NULL and I want to bring back all rows that have 0 and the NULLs

Simply put like this so I want to bring back on rows with 0 or the NULL / Blanks
WHERE Expired = '0'

Best Answer

Depending on indexing and size of data, you may find performance is better if you use:

SELECT * FROM table WHERE (col = 0 OR col IS NULL)

Or

SELECT * FROM table WHERE col = 0

UNION ALL

SELECT * FROM table WHERE col IS NULL