Hello I need help with this query I am writing in which if one of my parameters equals this value I want to grab it and get all the null values as well. I’m not quite sure how to go about writing this query. For example if my parameter is 1, then grab where all in the column are 1 and nulls as well, if value is 2 only get where value is 2, nothing else.
Select * From Table a //I have it something like this. Where a.Column1 = @Value
What you want is all the rows where
a.Column1 = @Value and
nulls only if
@Value = 1:
SELECT * FROM tablename WHERE (@Value = 1 AND Column1 IS NULL) OR (Column1 = @Value)