Limit of selections in IN clause

In a SQL select statement what is the limit for choices that i can give in a IN clause.For instance in the following example
select * from titles where title_id IN ( a,b,c,d,.....How far can it go.) What is the limit.
LVL 8
koppchaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan FranekCommented:
I haven't found any limit in manual, so I believe, that it's big enough :-) However, if you reach the limit, you can always by-pass it by storing your choices into some table and then use "select * from titles where title_id IN ( select choise from mychoices )"
0
leonstrykerCommented:
I am not sure about a limit. But I have done things like:

select * from titles where title_id IN (Select title_id From authors)

with the authors table containing well over 50,000 records.

However, I must point out that you would be better of avoiding such syntax if possible and use a JOIN if you can.  Even to a point of placing the values of the IN clause into a temp table.

Leon

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cckumarCommented:
I infact tend to believe there is an inherent sybase limit for a list of items that are explicitly listed out in the in clause, but not for nested SQL statements.

The limit on 12.5 appears to be 439. Try it and let me know.

I am postively certain that on older versions this limit used to be 200 items. So appears as if it has been increased.

Thanks.
0
ChrisKingCommented:
I can advise from experience that under 12.5.x that a list id 30 id's may not use the index, whereas 10 then 10 then 10 will always use the appropriate index.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.