LIKE condition in query
| From: | Don Hicks | Date: | Tue, 05 Nov 2002 18:49:35 +0000 |
| Subject: | LIKE condition in query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-122834@lists.php.net to get a copy of this message | ||
I'm writing an SQL query in a php 4.0 script. The query pulls data from an
MS Access '97 database through an ODBC connection.
I'm having difficulties creating a condition using "LIKE".
If I write the following expression, the query works:
$Query="
SELECT FieldName1, FieldName2
FROM TableName
WHERE FieldName1 = '$CriterionRecord'
";
But, if I change the Where statement from "=" to "LIKE", the query no longer
works, and I can't figure out why. (Could it be punctuation?) Here's an
example:
$Query="
SELECT FieldName1, FieldName2
FROM TableName
WHERE FieldName1 LIKE '$CriterionRecord'
";
The criterion record is actually chosen in another form and passed through
to this script. The criterion record may be a complete record, or it may be
a partial record with a wildcard, but the "LIKE" script is not working in
either case.
Does anyone have any experience with this they could share with me?
Sincerely,
Don Hicks
Portland, OR