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)
 Innerjoin using like is possible?

Author  Topic 

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-04-13 : 02:09:09
Hi, i have one requirement.

Table1

Col1 Col2
234 erekk
450 rerere
678 roroor

Table2

Col1 Col2
234-45 rtr
456-90 rtr
234-56 rrl
678-76 hhh

Now i want to retive the data as For the col1 in Table1 contains the data in Tabl2 in Col1.
i.e if i took 234 From table1, i want to know that what are the rows present in table2 starting with 234?

Output

Col1 Col2
234-45 rtr
234-56 rrl


G. Satish

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-13 : 02:40:39
select * from table2 as t2 inner join table1 as t1 on t2.col2 like t1.col1+'%'
where t1.col1=234

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -