Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want search code which will find all the text which is similar to a column in a table. PL/SQL also can applicable.

Example:
Suppose, I have 3 text in a column (Sample_text) of a table. I want to search 50 to 80 percent similarity text form a given text.

1. a. The Safety gate combined with one gate.
b. The Safety gate combined with three gates.
c. The Safety gate separated with others gates.

1. Output:
The Safety gate combined with one gate.
The Safety gate combined with three gates.
The Safety gate separated with others gates.


If I search through the text, "The Safety gate combined with one gate" then it will show all the three above text. Because those three text have more than 70 percent similarity in between those above three text.

But,

2. a. Important! save for (new AMII).
b. Important! keep instruction (AMII).

Output:
No match found.


Those couple of text does not have the 50 percent similarity in between that.
So, it will show nothing.
Posted
Updated 18-May-15 2:35am
v2
Comments
CHill60 18-May-15 8:23am    
Not clear. If you post an example it might help - post the sql you have already tried to give us a clue
Richard Deeming 18-May-15 10:20am    
Bittu14 19-May-15 4:36am    
But it has not clear for me.

1 solution

My best shot:
SQL
SELECT *
FROM TableName
WHERE ColumnData Like '%The Safety%'


I tried above on below example:
SQL
DECLARE @tmp TABLE (SomeText VARCHAR(255))

INSERT INTO @tmp (SomeText)
VALUES('1. a. The Safety gate combined with one gate.'),
('b. The Safety gate combined with three gates.'),
('c. The Safety gate separated with others gates.')

SELECT *
FROM @tmp
WHERE SomeText Like '%The Safety gate%'


See: Like (T-SQL)[^]
 
Share this answer
 
v2
Comments
Bittu14 18-May-15 8:37am    
I used that one. But it has not fulfilled the exact requirement. See the example I given above.
Maciej Los 18-May-15 8:45am    
Mylog.25 18-May-15 8:47am    
Try this link http://solutioncenter.apexsql.com/quickly-search-for-sql-database-data-and-objects/
Bittu14 18-May-15 8:48am    
I know. I want it in SQL only. Search engine optimization in pl/sql.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900