Hello.


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



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







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  the

> 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 https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
       <___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to