我给你写个例子:假设 第一条sql 是 select a.a1,a.a2,a.a3 from A a where ... 第二条sql是 select b.b1,b.b2,b.b3 from B b where ... 第三条sql 是 select c.c1,c.c2 from C c where ...那么合成一句的sql 是select x.x1,x.x2,x.x3,y.y1,y.y2,y.y3,z.z1,z.z2from (select a.a1 x1,a.a2 x2,a.a3 x3 from A a) x, (select b.b1 y1,b.b2 y2,b.b3 y3 from B b)y, (select c.c1 z1,c.c2 z2 from C c)zwhere x.x1 = y.y1 and y.y1=z.z1这里面需要注意的是 三张表必须有关系 否则无法合并
原文地址:https://www.cnblogs.com/a8457013/p/9090178.html
时间: 2024-11-01 20:46:43