Jump to content



  • Please log in to reply
1 reply to this topic

#1 severndigital

  • Members
  • PipPipPip
  • Advanced Member
  • 355 posts
  • LocationPA

Posted 02 March 2013 - 01:52 AM

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.


I have solved a vast majority of my own PHP questions simply by going to www.php.net and typing in the basis of my question.

I.E. ... how do i format a number with 8 decimals?

php.net search 'format number' ... it will get you where you need to be.

#2 vinny42

  • Members
  • PipPipPip
  • Advanced Member
  • 414 posts

Posted 12 August 2013 - 01:04 PM

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users