Differant queries

Pauldohert

Something in here
Local time
Today, 15:33
Joined
Apr 6, 2004
Messages
2,101
I have a list box and i want to construct a query based on the items selected.

I loop thru to get the ID that I want and end up with

SELECT Table1.ID, Table1.Name
FROM Table1
WHERE ((((Table1.ID) in (12,13,14))));

or

SELECT Table1.ID, Table1.Name
FROM Table1
WHERE (((Table1.ID)=12)) OR (((Table1.ID)=13)) OR (((Table1.ID)=14));

Whats the advantage of one over the other - I presume I can handle more selected items the first way - because the string for the query is shorter?

Thanks
 
The IN creates an internal table (in memory if short enough) that it joins to (basically) while the other has to create a seperate condition check for each value.
In reality the second should be slower, but I doubt you would see any difference unless it was a huge table or had a lot of conditions.
 

Users who are viewing this thread

Back
Top Bottom