Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL IN clause which is guaranteed to evaluate to false

Is there any value which I can place in a SQL IN clause which will guarantee that the clause will evaluate to false?

SELECT *
FROM Products
WHERE ProductID IN (???)

Is there anything I could replace ??? with to guarantee no rows will be returned?

like image 749
Ian Newson Avatar asked Jun 17 '15 09:06

Ian Newson


1 Answers

Replace with NULL. There is no better guarantee!

Because no other value can equal to NULL, even NULL itself.

And this is kinda universal value for any type(as @zohar-peled mentioned).

like image 117
Giorgi Nakeuri Avatar answered Oct 20 '22 17:10

Giorgi Nakeuri