Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how in clause in SQL server works

I would like to know how comparisons for IN clause in a DB work. In this case, I am interested in SQL server and Oracle.

I thought of two comparison models - binary search, and hashing. Can someone tell me what method does SQL server follow.

like image 913
mutelogan Avatar asked Oct 29 '25 12:10

mutelogan


1 Answers

SQL Server's IN clause is basically shorthand for a wordier WHERE clause.

...WHERE column IN (1,2,3,4)

is shorthand for

...WHERE Column = 1
OR Column = 2
OR column = 3
OR column = 4

AFAIK there is no other logic applied that would be different from a standard WHERE clause.

like image 148
JNK Avatar answered Oct 31 '25 02:10

JNK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!