Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining tables with a like wildcard

Status
Not open for further replies.

ciarra41

Technical User
Sep 11, 2006
116
US
I trying to join two tables with table a has a single value whereas the table b may have multiple values but still has the value in table a.

Possible easy fix?

select a.* FROM
tableA as a
inner join
tableB as b
on b.CODE = LIKE '%'[a.code]'%'
 
And all together now:

Code:
Select a.*
FROM tableA a
JOIN tableB b ON
b.Code LIKE '%'+a.Code+'%'

Note this is expecting something like:
a.Code[tab]b.Code
AAA[tab]AAA BBB
AAA[tab]CCC DDD AAA
BBB[tab]EEE BBB DDD


Lodlaiden


You've got questions and source code. We want both!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top