July 1, 2008 at 2:53 pm
Hello.
I need to join two tables (each table has only 1 column).
The problem is that the record from one table may exist in the other column buried between other text.
Example
Column1 Column2
99505 GHS 99505 437
Is there a way to join these two???
Thanks,
AT
July 1, 2008 at 2:57 pm
You can use the Like operator in joins.
select *
from dbo.Table1
inner join dbo.Table2
on Table1.Col1 like '%' + Table2.ColA + '%' -- Table1.Col1 contains Table2.ColA
or Table2.ColA like '%' + Table1.Col1 + '%' -- vice versa
It'll crawl, because it can't possibly use indexes for this, but it'll work. Depending on how the data works, full text indexing might be a better solution.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
July 1, 2008 at 3:00 pm
Thanks.
Worked like a charm!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply