Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

WHERE clausola che utilizza valori che potrebbero essere NULL

Basta usare la logica AND/OR ad es.

SELECT *
FROM Customers
WHERE ((Firstname IS NULL AND @firstname IS NULL) OR Firstname = @firstname)
AND ((Lastname IS NULL AND @lastname IS NULL) OR Lastname = @lastname);