Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Use of IN method instead of OR operater

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-05-15 : 07:18:16
raghavendra writes "i am using the following sql statement
select id,status from invoice where (status = 13 or status =14 or status = 15)
is this query increase the performance or i need to change the query to this
select id,status from invoice status IN(13,14,15)
suggest me which query i need to use, to enhance the performance."

dsdeming

479 Posts

Posted - 2003-05-15 : 07:57:28
I just ran a test of both methods, and the Query Execution Plans were identical. In that case, why not use the syntax that's easier to read and to write.

HTH

Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-05-15 : 09:07:56
Agreed. should be exactly the same. I like IN(), it's shorter and a little easier to "comprehend".

(except when one of the listed values is NULL, in which case it gets pretty confusing -- looking at the OR's tends to make more sense.)

- Jeff
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-05-15 : 13:14:29
quote:

suggest me which query i need to use, to enhance the performance



Might not be the query syntax if you're looking to increase performace. How many rows of data are there? Is there an Index on Status? What's the cardinality of the data?



Brett

8-)
Go to Top of Page
   

- Advertisement -