I have the following query :
SELECT * FROM `user`
WHERE MATCH (user_login) AGAINST (\'supriya*\' IN BOOLEAN MODE)
Which outputs all the record
I believe the selection of FULL-TEXT Searching
isn't relevant here. If you are interested in searching some fields based on wildcards like:
%word%
( word anywhere in the string)word%
( starting with word)%word
( ending with word)best option is to use LIKE
clause as GolezTrol has mentioned.
However, if you are interested in advanced/text based searching, FULL-TEXT
search is the option.
Limitations with LIKE:
There are some limitations with this clause. Let suppose you use something like '%good' (anything ending with good). It may return irrelevant results like goods
, goody
.
So make sure you understand what you are doing and what is required.
Match doesn't work with starting wildcards, so matching with *abc*
won't work. You will have to use LIKE
to achieve this:
SELECT * FROM user WHERE user_login LIKE '%abc';
This will be very slow however.
If you really need to match for the ending of the string, and you have to do this often while the performance is killing you, a solution would be to create a separate column in which you reverse the strings, so you got:
user_login user_login_rev
xyzabc cbazyx
Then, instead of looking for '%abc'
, you can look for 'cba%'
which is much faster if the column is indexed. And you can again use MATCH if you like to search for 'cba*'
. You will just have to reverse the search string as well.