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
 General SQL Server Forums
 New to SQL Server Programming
 partial match of data between two tables

Author  Topic 

Jaytaba
Starting Member

1 Post

Posted - 2011-01-24 : 09:25:03
I m trying to compare data from two separate tables in a database,

Sample of Data in Table1:

name1:
(500) Days of Summer (2009)
Around the World in 80 Days (2004)
Around World in Eighty Days (1956)

Sample Data in Table2:

name2:
500 Days of Summer.iso
Around the World in 80 Days.iso

My goal is to list the data side by side:

Table1 | Table2
--------------------------- | -----------------------
(500) Days of Summer (2009) | 500 Days of Summer.iso
Around the World in 80 Days(2004) | Around the World in 80 Days.iso
Around World in Eighty Days (1956) | Around the Worold in 80 Days.iso


I tried joining the tables and with Like comparison but getting Nulls on one side, Will appreciate any suggestions on the best way to handle the query.



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-24 : 10:13:16
some thing like

SELECT *
FROM Table1 t1
INNER JOIN Table2 t2
ON t2.name2 LIKE REPLACE(REPLACE(t1.name1,'(',''),')','') + '.%'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -