On Tue, 2011-09-13 at 09:48 -0700, David Harkness wrote:
> On Tue, Sep 13, 2011 at 7:29 AM, Ashley Sheridan
> <a...@ashleysheridan.co.uk>wrote:
> > SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)
> >
> +1. And this is a great place to use implode():
>     $sql = 'select ... where userID in (' . implode(',', $ids) . ')';
> David

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

good luck!


Steve Staples
Web Application Developer

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to