That’s a good argument which shows how complicated this logic can become once NULL is involved either in the column value or the argument itself.
In the case of @springnotes, from what I can see,
myId
is generally notNULL
, but his param may beNULL
.
I think that myId
can be null as mentioned by the OP in his first post:
If myID is null then use this query
So, if we run this query:
SELECT * FROM (VALUES ('foo'), ('bar'), (null)) AS vals(myId) WHERE null IS NULL OR myId = null;
we get:
"foo"
"bar"
""
Which is not exactly what the OP requested either since he might have wanted to skip that row with NULL values.