0

I am trying to query a table with a phrase and get results that fully match my phrase. For example if I search for

WHERE CONTAINS(prc.SectionContent, '"check this"') 

I get results that contain the specific words too.

I would like it it behave like a wildcard search such as:

WHERE SectionContent LIKE '%check this%'

which returns results that have the full phrase only.

jarlh
  • 42,561
  • 8
  • 45
  • 63
Robbie Dee
  • 39
  • 2
  • 7
  • Which dbms are you using? – jarlh Jan 06 '20 at 14:59
  • Microsoft SQL Server and MSM – Robbie Dee Jan 06 '20 at 15:09
  • The wildcard search doesn't give you what you want? – Mason Chambers Jan 06 '20 at 16:10
  • It does but it takes about 0.6 seconds on average to execute whilst FREETEXT executes in 0.05 on average. This really makes a difference for my application. – Robbie Dee Jan 06 '20 at 16:56
  • Does this answer your question? [FREETEXT queries in SQL Server 2008 not phrase matching](https://stackoverflow.com/questions/4462875/freetext-queries-in-sql-server-2008-not-phrase-matching) – Ross Presser Jan 06 '20 at 20:02
  • OP from that thread is using FREETEXT which returns results that contain individual words as well as phrases. Suggested solution asks OP to use CONTAIN instead which is what I'm doing however, it is still returning some results with individual words as well as full phrases in some instances. – Robbie Dee Jan 07 '20 at 09:15
  • @RobbieDee Your CONTAINS example should have worked. Placing multiple words within double quotes, like you did, should yield results that contain the exact phrase "check this" within its text. Can you give an example where this didn't happen? – Keith Jan 28 '20 at 16:27

1 Answers1

0

Try using;

WHERE SectionContent LIKE 'check this'

If you remove the % (wildcards) it will search just the text.

ibarrond
  • 6,617
  • 4
  • 26
  • 45