RE: [PHP-DB] adding a space in mysql

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: RE: [PHP-DB] adding a space in mysql
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20928@lists.php.net to get a copy of this message
Richard, You are correct. For Ron to achieve his goal, the SQL needs to be changed to: 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'; php-db@lists.php.net Subject: RE: [PHP-DB] adding a space in mysql I haven't set up any text-based searches before, but when you say: <snip> If the user types 'Wash' I don't want any matches for 'Washington', 'Washing', etc. <snip> 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 "Wash")? 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:wallace1248@yahoo.com] Sent: Wednesday, July 31, 2002 4:32 PM To: php-db@lists.php.net 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 http://health.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php .

« previous php.db (#20928) next »