severndigital Posted March 2, 2013 Share Posted March 2, 2013 I know most of this issue is me not knowing how to use SIMILAR TO and regex so any help would be great. I am trying to match a product title entered into a search field with titles already in a database. for example in the database the title is "Robocop" when I look up another title say ... "Robocop Blu-Ray" or "Robocop (The Criterion Collection)" or "Prime Directives Robocop Series" how can I get it to return a match? Thanks in advance. C Link to comment https://forums.phpfreaks.com/topic/275107-similar-to-issue/ Share on other sites More sharing options...
vinny42 Posted August 12, 2013 Share Posted August 12, 2013 Sounds like you can get away with a simple LIKE statement: WHERE title LIKE '%' || your_string_here || '%' The % signs are wildcards and the || signs append the who thing together to become '%Robocop%' Note however that LIKE statements that start with a wildcard can be very slow because the database cannot use indexes to eliminate records that cannot possibly match. FULLTEXT may be a better solution, but is (a little) more complex to setup Link to comment https://forums.phpfreaks.com/topic/275107-similar-to-issue/#findComment-1444506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.