Sorry for asking what should be a fairly simple question.
Say I have the search term "myzoo" and a database entry "zoo" how would I go about getting it to match?
Or in other terms, how can I get mysql to match the last part of a search term.
thanks very much guys, I'm incredibly stuck with this.
% is a wild card.
where blah_field like '%zoo'
Of course, if case is a problem, you can use
where upper(blah_field) like '%ZOO'
MySQL is case-insensitive. Is there actually any way to tell it to be case-sensitive? Not that I need it, I'm just curious. Sand Devil is spot on though.
Looking at Sand_Devil's example of
You can tell columns or whole tables to be case-sensitive by assigning an appropriate collation (ending in
Sorry, I didn't explain properly.
I want the opposite of that.
I need this string "myzoos" to match the database entry "zoos", not the other way round as I must have suggested.
I'm using ci so upper is irrelevant.
Imagine I need to use a wildcard on the actual database entries:)
SELECT FROM dictionary where word LIKE '%myzoo'
will throw up things like mamyzoo, dobdomyzoo ect,. but not just "zoo"
If I understand what you are suggesting... word being the entered string and blah_field being the database entry. || allows you to concatenate strings. To search for the % you need to place an escape, usually \
where word like ('%'||blah_field)
Should do the trick.
I had to use CONCAT but the details you gave me helped me solve it within minutes!
|All times are GMT. The time now is 11:55 PM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0