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

From: Date: Tue, 13 Sep 2011 19:42:33 +0000
Subject: Re: Querying a database for 50 users' information: 50 queries or a WHERE array?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-314814@lists.php.net to get a copy of this message
On Tue, Sep 13, 2011 at 21:06, Steve Staples <sstaples@mnsi.net> wrote: > I mentioned that implode earlier, but there is also the underlying > question (which I also asked earlier)... how is he getting the 50 id's > to populate? > > here are 2 other ways of skinning the cat: > > using an inner join: > select table.* from table inner join othertable on (table.userid = > othertable.userid) where (use the way your getting the 50 id's here); > > OR by using a subselect, > select * from table where userid IN (select group_concat(userid, > separator ', ') FROM othertable where (using logic here)); > > guess it all depends on how you want to do it...  but that would make it > 1 db query > I personally would stick with the inner join as I know that syntax, but thanks for introducing me to the subselect. I have never seen that. -- Dotan Cohen http://gibberish.co.il http://what-is-what.com

« previous php.general (#314814) next »