Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Insert an array into a query


Message #1 by Jefferis Peterson <jefferis@p...> on Wed, 02 Oct 2002 15:39:53 -0400
SQL doesn't work like that. Remember, all you are doing is building a
literal string to send to your database. The database processes the SQL.

So, you'll need to construct a string which contains:

WHERE
    Field1 LIKE '%firstcriteria%'
OR
    Field1 LIKE '%secondcriteria%'
OR
    Field1 LIKE '%thirdcriteria%'

(change OR to AND depending on what you're trying to accomplish)

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Jefferis Peterson" <jefferis@p...>
Subject: [sql_language] Insert an array into a query


: I'm trying to figure out how to turn  multiple words from a text field
input
: form into an array for a query.  I realize the first part of the problem
is
: to create the array, but assuming I've done that and I get the results of
: $word1, $word2, and $word 3
:
: How do I input that into a query
:
: Select * from Catalog where Catalog.keywords  like "%". $array . "%"
:
: Perhaps it isn't possible and you have to use AND for each result, set a
: maximum  in your php?
:
:
: Just curious
:
: Jeff
: ~~~~~~~~~~~~
: Jefferis Peterson, Pres.
: Web Design and Marketing
: http://www.PetersonSales.net
: Tel .  xxx-xxx-xxxx
: ICQ 19112253
:
: http://www.Slippery-Rock.com - 7,000 hits per year
:
:


  Return to Index