Bluehost.com Web Hosting $6.95

SELECT... WHERE id IN list_of_ids , avoiding loop ?

This is a discussion on SELECT... WHERE id IN list_of_ids , avoiding loop ? within the MySQL Database forums, part of the Database Forums category; I have a set of id's : city_ids = [ id1, id2, ..... idn] to select all proposals where proposals.city_id is in ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-19-2006
Josselin
 
Posts: n/a
Default SELECT... WHERE id IN list_of_ids , avoiding loop ?

I have a set of id's : city_ids = [ id1, id2, ..... idn]

to select all proposals where proposals.city_id is in this set,

1- I can loop over the list items
2- I can create a temporary table of selected_id's and match it with
the proposals table
3- I can use the where.. in .. clause, select * from proposals WHERE
proposals.city_id IN id1, id2, ..... idn, which should be the best
option, but if this set is large (10 to 400 items) I can explode the
SELECT clause string limit...

any suggestion ?... performance is obviously my concern

thanks for your lights

joss

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 03:00 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0