faqts : Computers : Programming : Languages : PHP : Common Problems : Ecommerce

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 7 people (29%) answered Yes
Recently 2 of 7 people (29%) answered Yes

Entry

Re: mySQL/PHP search - Is there a faster alternative to the 'like' query? Thanks!

Apr 10th, 2004 08:15
Matt Chatterley, Mark Hermansen,


Maybe - it depends on exactly what you want to achieve.
One good thing to know is that indexes will only be used (I believe) if
you do not have a % at the start of the string you are trying to match,
i.e. LIKE 'fred%' will use available indexes (if any exist), while LIKE
'%fred%' will not.
You may also be able to use the function FIND_IN_SET to speed things up
if you are comparing words (or part words) which are in a column to a
longer string E.G: FIND_IN_SET('fred', 'fred,the,goldfish') should return 1.