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 2005 Forums
 Transact-SQL (2005)
 joining tables on like???

Author  Topic 

squarefish
Starting Member

28 Posts

Posted - 2009-08-03 : 04:13:22
Hi there,

Is it poosible to have 2 tables joined on a like rather than equals?

I have two tables one contains descriptive colours like metallic steel silver, chilli Red, and the other has red, silver, black, blue etc.

I want to be able to say chilli red = red, metallic steel silver = silver.

Is there a way of achieving this??

Many Thanks

Richard

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-08-03 : 04:38:22
use like or patindex
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-03 : 05:09:15
[code]
from table1 t1 inner join table2 t2 on t1.color like '%' + t2.color + '%'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

squarefish
Starting Member

28 Posts

Posted - 2009-08-03 : 05:52:36
<-- Feels slightly stupid he didn't try that first! :-)

Thanks!
Go to Top of Page
   

- Advertisement -