0

I have this query:

select id from mytable where contains(all_text,'('||?||' within name)*2,
('||?||' within description)',1)>0

How does the contains in the where clause work?

Thanks,

Sean Nguyen
  • 12,528
  • 22
  • 74
  • 113
  • See [Stack Overflow How does contains() in PL-SQL work?](http://stackoverflow.com/questions/2431054/how-does-contains-in-pl-sql-work) – Appleman1234 Feb 12 '12 at 02:46

1 Answers1

1

If the first parameter occurs in the name section, then its weight is twice the weight of the second parameter occurring in the description section.

This "contains" operator will set the score variable. Without it doubling the weight has no meaning for ">0" condition. However,

SELECT id FROM mytable WHERE CONTAINS(all_text,'('||?||' WITHIN name)*2,
('||?||' WITHIN description)',1)>0 ORDER BY SCORE(1) DESC 

would totally make sense and will order id's first by those rows where search term is found in the name section.

Here is a useful reference, just in case: http://docs.oracle.com/cd/B19306_01/text.102/b14218/cqoper.htm

Alex Pakka
  • 9,466
  • 3
  • 45
  • 69