create procedure tt()
begin
if exists(select x.a from t1 x where x.a='a1' limit 1) then
if exists(select y.b from t1 y where y.b='b2' limit 1) then
if exists(select z.c from t1 z where z.c='c3' limit 1) then
if exists(select n.d from t1 n where n.d='d4' limit 1) then
select x.a,y.b,z.c,n.d from t1 x,t1 y,t1 z,t1 n;
end if;
end if;
end if;
end if;
end
然后我自己写了一下 出来结果是一个笛卡尔积 判断语句跟没加一样 怎么正确写一下啊
大概就是一张表四个字段 ABCD 然后各自有四个值 a1 a2 a3 a4 b1 b2 b3 b4 c1 c2 c3 c4 d1 d2 d3 d4
q请教一下怎样实现判断A 是否为a1 如果是a1 然后a1与b2关联 B字段就是b2 如果B字段是b2然后判断一下C字段是否是c3 如果是c3那么D字段就是d4
最后输出结果是a1b2c3d4 我知道可以吧t1表虚拟成四张表然后做一个关联 限定一下ABCD的值也可以求出来a1b2c3d4但是与要求用的方法不一样 有没有大佬看看这个功能怎么实现 谢谢了