You are correct. For Ron to achieve his goal, the SQL needs to be changed

WHERE name = '$var'

If you use the LIKE operator and have a trailing %, that is telling mySQL to
match the first characters exactly and then match ANY trailing characters.
If you use the equals operator, then you are guaranteed an exact match. If
you are concerned about matching any case, then set both strings to UPPER
case then do the compare.

Jim Hunter

-------Original Message-------

From: Hutchins, Richard
Date: Wednesday, July 31, 2002 13:48:17
To: 'ron wallace'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] adding a space in mysql

I haven't set up any text-based searches before, but when you say:
If the user types 'Wash' I don't want any matches for
'Washington', 'Washing', etc.
Aren't you, in essence, saying that you want to search for "Wash"? Meaning
that your query could just say WHERE name = '$var' (where $var is set to

According to the MySql manual, the equal comparison operator works on
strings and numbers. But maybe text searches work differently than I thought
and it will return strings wherever the letter combination "wash" appears.
If that's the case I'm sure somebody will correct me and I'll learn
something in the process.

-----Original Message-----
From: ron wallace [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 4:32 PM
Subject: [PHP-DB] adding a space in mysql

How can I add a space to the end of a varchar string
in mysql? I can't seem to do it directly, and I tried
str_pad and other things, but no luck so far. The db
doesnt hold the value of the space...its getting
trimmed somewhere(?)

The reason I want to do this is so I can search for
exact matches on one word strings without stemming:
....WHERE name LIKE '$var %'.

If the user types 'Wash' I don't want any matches for
'Washington', 'Washing', etc.

Thank You All

Do You Yahoo!?
Yahoo! Health - Feel better, live better

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:


Reply via email to