What would be the difference between doing:
SELECT person FROM population WHERE id = 1 or id = 2 or id = 3
and –
SELECT person FROM population WHERE id IN (1,2,3)
Are they executed the exact same way? What difference is there? Would there ever be a reason where one would you IN rather than multiple =‘s?
No, they perform the same thing. The
INminimizes the query string. That’s all. Such statements help in query optimization.One difference in these two comparison operators would be that
INuses aSETof values to compare, unlike the “=” or “<>” which takes a single value.According to the manual: