Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Match Data !!

Author  Topic 

M2
Starting Member

22 Posts

Posted - 2002-06-13 : 05:30:32
I want to retrieve NAME, which having the similarity. Other then LIKE, do have any other method to compare it?

Example:

Table A:

Name
-------------------------------------------------
LIM AH KAU
SHAMINI A/P GURUSAMY
ABDUL HALIM BIN ABDUL MAJID
ABDUL RAHIM BIN ATAN


Table B:

Name
--------------------
BIN ATAN
STEVEN LIM AH KAU
ABDUL HALIM


Script:

Select * from TableA, TableB
Where TableB.Name like '%' + TableA.Name + '%'


Result only display:

Name Name
----------------------------------------------------
LIM AH KAU STEVEN LIM AH KAU


I know that ABDUL HALIM BIN ABDUL MAJID and ABDUL HALIM is the same person. However, if I use above method, the result do not display it.


Do have any method that can find out the similarity of two records from different table?


Wanderer
Master Smack Fu Yak Hacker

1168 Posts

Posted - 2002-06-13 : 05:57:58
well, just expanding on your query:

Select * from TableA, TableB
Where TableB.Name like '%' + TableA.Name + '%'

to the following :


Select * from TableA, TableB
Where (TableB.Name like '%' + TableA.Name + '%' )
or (TableA.name like '%' + tableB.Name + '%' )

will include the missing row I think ( I haven't tested, some you should do so).



Go to Top of Page

M2
Starting Member

22 Posts

Posted - 2002-06-13 : 22:45:44
I also do like that before, but still cant get what I want ! Do have any other method?

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-06-14 : 07:55:45
You might need to trim the expressions before you do the comparison. It seems your query should work. What is the date type for the [name] column in the two tables?

Can you just please post the create table statements(ddl) and the insert statements(dml) necessary to reproduce your problem?

<O>
Go to Top of Page
   

- Advertisement -