Jump to content

SIMILAR TO issue


severndigital

Recommended Posts

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
Share on other sites

  • 5 months later...

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
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.