问个查询语句
2个表 例如 base , user
base的字段 id , name
1 a
2 b
3 c
user的字段 id1, id2, id3
1 2 3
如何查询user表最后显示 a b c 在线等~
------解决方案--------------------create table base(id int, name varchar(10))
insert base select 1, 'a '
union all select 2, 'b '
union all select 3, 'c '
create table [user](id1 int, id2 int, id3 int)
insert [user] select 1, 2, 3
select
id1=A.name,
id2=B.name,
id3=C.name
from [user]
left join base as A on [user].id1=A.id
left join base as B on [user].id2=B.id
left join base as C on [user].id3=C.id
--result
id1 id2 id3
---------- ---------- ----------
a b c
(1 row(s) affected)