List:General Discussion« Previous MessageNext Message »
From:T.J. Mahaffey Date:October 10 2005 6:26pm
Subject:Re: Select values based on array containment?
View as plain text  
> In my opinion you have two choices (hope someone has better :).
> First - you can generate dynamically your query (the IN part
> of your query). See definition of the IN operator at:
>   http://dev.mysql.com/doc/mysql/en/comparison-operators.html

This would be my plan at the moment.
I sought out the IN operator in an effort to avoid doing a zillion  
subqueries to 'gather' the rows I want.
(ie. Repeat a query on every item in the pre-existing array, asking  
MySQL some 9,000 times whether or not each item exists in a row in  
the table. In my mind, this would be terribly inefficient.

The IN operator seems to remedy this.

> Second available way is to create a temporary table from the
> array contents and use IN subquery. See:
>   http://dev.mysql.com/doc/mysql/en/any-in-some-subqueries.html

Creating tables on the fly isn't something I've ever considered or  
experimented with. I'll have a look at that as well.
Thanks much for your input.

--
T.J. Mahaffey
tj@stripped



Thread
Select values based on array containment?T.J. Mahaffey9 Oct
  • Re: Select values based on array containment?SGreen10 Oct
  • Re: Select values based on array containment?Gleb Paharenko10 Oct
    • Re: Select values based on array containment?SGreen10 Oct
      • Re: Select values based on array containment?T.J. Mahaffey10 Oct