Re: Querying a database for 50 users' information: 50 queries or a WHERE array?

From: Date: Wed, 14 Sep 2011 18:01:46 +0000
Subject: Re: Querying a database for 50 users' information: 50 queries or a WHERE array?
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-314854@lists.php.net to get a copy of this message
You can use a limit with a nested select, you just can't use it in some cases, like inside an "IN" statement, but something like this should work: SELECT id, data, etc FROM table JOIN (SELECT special_id as id FROM special_table ORDER BY special_id LIMIT 0, 1000) AS table2 USING (id) Note: syntax may not be valid, but should be fairly straight forward to fix, have no time to play with it though... -- The trouble with programmers is that you can never tell what a programmer is doing until it’s too late.  ~Seymour Cray On Wed, Sep 14, 2011 at 4:12 AM, Dotan Cohen <dotancohen@gmail.com> wrote: > > On Wed, Sep 14, 2011 at 06:05, chetan rane <chetan.d.rane@gmail.com> wrote: > > Hi, > > > > There are 2 peoblems with subselect > > > > 1. You cant use a limit on the nested select > > 2. Id the number of elements in the in clause exceeds the subselect buffer > > you will run into performance issues ans eventually you query will be > > doomed. Inner joins in,this is the best option for this . You can use a temp > > table for this > > > > Thanks Chetan. I will keep that in mind if I ever get around to > learning about subselects. > > Have a great day! > > -- > Dotan Cohen > > http://gibberish.co.il > http://what-is-what.com

« previous php.general (#314854) next »