create table A
(
A1 varchar(10),
A2 varchar(10)
)
insert into A values("x","y")
create table B
(
B1 varchar(10),
B2 varchar(10)
)
insert into B values("x","x1")
insert into B values("x","x2")
insert into B values("y","y1")
insert into B values("y","y2")
insert into B values("y","y3")
具体地
即根据A表中的x,y对应关系,把x,y的下级数据也对应起来.这样的要求可以用sql实现吗?请大家帮帮忙。
解决方案
20
select t1.B2,t2.B2
from A , b t1, b t2
where a.A1=t1.b1 and a.A2=t2.B1
from A , b t1, b t2
where a.A1=t1.b1 and a.A2=t2.B1
20
select a.B2,c.B2 from B a,A b,B c where a.B1 = b.A1 and b.A2 = c.B1 order by a.B2;