Oracle CONTAINS issue

1.6k Views Asked by At

so I'm stumped here. I'm using Oracle 12.2.

Say I have 2 records in table "t" where the SEARCH_NAME column is indexed by type CONTEXT:

SEARCH_NAME
-----------------
REED, JAMES D
REED, JAMES J

I want to search for the first record (REED, JAMES D) using the CONTAINS operator. I would've expected this to work, but it does not as it will return both records. Anyone have any idea how to get only the first?

SELECT search_name
  FROM contacts 
 WHERE CONTAINS(search_name, 'REED\, JAMES D') > 0;
1

There are 1 best solutions below

0
Ashish Mishra On
SELECT search_name
  FROM contacts 
 WHERE CONTAINS(search_name, 'REED\, JAMES D', 1) > 0;

Find more on:

Contains for String

How contains works