select
a.col,
col1 = max(case when a.col1=b.name then b.level end),
col2 = max(case when a.col2=b.name then b.level end),
col3 = max(case when a.col3=b.name then b.level end)
from
tab_a a
corss join
tab_b b
group by
a.col
a.col,
col1 = max(case when a.col1=b.name then b.level end),
col2 = max(case when a.col2=b.name then b.level end),
col3 = max(case when a.col3=b.name then b.level end)
from
tab_a a
corss join
tab_b b
group by
a.col
from tab_a A
join tab_b B
on A.col1-A.col3=B.name
http://community.csdn.net/Expert/topic/4185/4185456.xml?temp=.6703607