Hi,

On Mon, Mar 19, 2001 at 01:23:56AM -0600, Jason Landry wrote:
> I know that this response was directly related to a question about
> subqueries, but I think it's important to point this out, because I almost
> didn't pursue this avenue as a result.
> 
> As Fred pointed out, MySQL does not support IN and NOT IN, but *only* in the
> case of subqueries:
> 
> select * from table 1 where id in (select id from table2)
> 
> However, it DOES support IN and NOT IN as long as a subquery is not used:
> 
> select * from table 1 where id in (115,515,614,23,51,24,15,12,51,23)
> 

Ah yes, thanks for correcting me. I use the constant IN frequently as well.
It can even be useful in some cases to replace sub-queries by serialized
queries if you know the result isn't a very large set of values.

I believe MySQL optimizes matches against the list of values by putting them
in a hash table, but by doing two queries you'll send the result of the first
('sub'-select) back and forth which is not very efficient. You may even bump
into the size limit of query packets (16M).


Fred.

-- 
Fred van Engen                              XO Communications B.V.
email: [EMAIL PROTECTED]             Televisieweg 2
tel: +31 36 5462400                         1322 AC  Almere
fax: +31 36 5462424                         The Netherlands

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to