select top 1 b.id,x =(select a from a where id=(select top 1 x from b)),y=(select a from a where id=(select top 1 y from b)),z=(select a from a where id=(select top 1 z from b)) from a inner join b on a.id=b.id
呵呵 写的有点乱
呵呵 写的有点乱
再次请问:能根据表2的id的不同而动态变更吗?例如:当表二的id为2时,则显示为
id x y z
2 a b c谢谢!
create proc dbo.tt
@id int
as
select top 1 b.id,x =(select a from a where id=(select x from b where id=@id)),y=(select a from a where id=(select y from b where id=@id)),z=(select a from a where id=(select top 1 z from b where id=@id)) from a inner join b on a.id=b.id
执行
exec tt 1