HQL query select one set of columns vs select other columns when a particular column is null

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 not NULL , but his param may be NULL .

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.