Subject | "IN" and several "=" and "and" |
---|---|
Author | james_027 |
Post date | 2005-05-25T06:12:58Z |
which performs much faster
select *
from table
where id = 1 and id = 2 and id = 4 and id = 6 and id = 8 and id = 10
or
select *
from table
where id in (1, 2, 4, 6, 8, 10)
The ID field is a primary key. And what if the field is not an index
key is there a need to be indexed for better performance.
Thanks
Regards,
James
select *
from table
where id = 1 and id = 2 and id = 4 and id = 6 and id = 8 and id = 10
or
select *
from table
where id in (1, 2, 4, 6, 8, 10)
The ID field is a primary key. And what if the field is not an index
key is there a need to be indexed for better performance.
Thanks
Regards,
James