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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 13, 2011 at 17:34, Steve Staples <sstaples@xxxxxxxx> wrote:
> what criteria are you using to get the "stats" for these 50 users?
>

They are passed as an array into a function I'm cleaning up.


> also, wouldn't this be much better suited for the mysql mailing list?
>

Yes.


> if you know all the userids, then you could just do it as:
>
> $sql = "SELECT * FROM table WHERE userid IN (". implode(', ',
> $usersids) .")";
>
> not very elegant, and I am not sure that the IN is any better than doing
> 50 mysql calls, but this is only 1 call, and gets you the data.
>

This is exactly what I need, thanks!


> Are you querying the database to get the id's in the frist place?  if
> so, you could look at doing an inner join on the 2 tables.
>

Actually, I do suspect that is where it's coming from. But the calling
function is not in my hands.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux