Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IN Keyword versus OR keyword

Tags:

tsql

Does it make much difference if I use in either of the following in a WHERE clause:

WHERE [Process Code] = 1 AND ([Material ID] = 'PLT' OR [Material ID] = 'BMI')

--or

WHERE [Process Code] =  1 AND [Material ID] IN ('PLT', 'BMI')

Would there be a time I would use one instead of the other?

like image 371
dotnetN00b Avatar asked Dec 21 '22 10:12

dotnetN00b


1 Answers

I can't think of a time I would use the first option. The second option is much cleaner and more expressive. And if it ever needs to be converted into a sub-select, it'll be easier to do.

like image 180
BishopRook Avatar answered Mar 03 '23 07:03

BishopRook