Re: adding a space in mysql
| From: | Dan Koken | Date: | Wed, 31 Jul 2002 22:29:30 +0000 |
| Subject: | Re: adding a space in mysql | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20929@lists.php.net to get a copy of this message | ||
Ron
I do believe that placing a space in '%$var %' will do the same as a varchar and sprip it off the end. Not positive. However I believe something like this will do the trick:
SELECT something
FROM a_file
WHERE replace(CONCAT_WS('','.',a_file.field,'.'),' ','.') LIKE '%.$var.%'
HTH... Dan
Ron Wallace wrote:
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