Gleb Paharenko <gleb.paharenko@stripped> wrote on 10/09/2005 05:17:20
> 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:
> Second available way is to create a temporary table from the
> array contents and use IN subquery. See:
> T.J. Mahaffey wrote:
> > I'm working on a PHP script which will already have gathered a large
> > array of string values from a text file. These values will correspond
> > to item numbers in a MySQL table. What I need to do is select rows in
> > the table based on whether or not their "item_number" values are in
> > pre-existing PHP array. (The idea here is that the website's inventory
> > comes in as a text file. I need to compare that inventory with the
> > items contained within the table and disable the catalog items which
> > are not in current inventory.)
> > Something like this (obviously not real code, just an illustration of
> > what I'm trying to get):
> > SELECT * in $mytable WHERE in_array('item_number', $arrayfromtextfile)
> > = true
> > Of course, in_array() is a PHP function, but I'm hoping there is
> > something similar available in MySQL.
> > Is this possible?
> > Thanks in advance for any insight someone might provide.
> For technical support contracts, goto
> This email is sponsored by Ensita.NET http://www.ensita.net/
> __ ___ ___ ____ __
> / |/ /_ __/ __/ __ \/ / Gleb Paharenko
> / /|_/ / // /\ \/ /_/ / /__ Gleb.Paharenko@stripped
> /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.NET
> <___/ www.mysql.com
If you are going so far as to turn your list of values into a temporary
table, you could go ahead and use a JOIN instead of a subquery.
Unimin Corporation - Spruce Pine