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 23:04, Alex Nikitin <niksoft@xxxxxxxxx> wrote:
> Dotan,
>
> IN (the function used in all of the queries above) is not the same as an
> INNER_JOIN, inner join joins 2 tables, as you have already described, IN
> however is a function that return 1 if the value being searched for is in
> the array of its values or 0 if it is not, thus IN is not an inner join, but
> a comparator function, thus if you are using IN, limit will indeed be more
> efficient than it's omission for exactly the reason i have stated in my
> previous post. Because your user array seems to be in php, and implode has
> been a topic of discussion above as well, setting an adequate limit is a
> simple task with the php's count function.
>

Yes, I did realize that after seeing the syntax of IN, which I have
not been exposed to before. My response that you quoted was in
response to a suggestion that a LIMIT clause be used with an INNER
JOIN query, which is wrong on two principles.


> This is all ofcourse void if the user array being pulled from mysql, in
> which case you could simply join the two tables to get your resulting data
> set. The trick there is to use the USING clause which seems to run a lot
> faster than any ON clause, or work on an optimized subselect, especially if
> you are running a cluster.
>

Agreed. In fact I don't know from where the array is coming, that's
not my part of the code! But I agree that if it is coming from mysql
then a join would be preferable.


-- 
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