请教一个4表混合连接的SQL
表:t1,t2,t3,t4t1与t2做等值连接,t3,t4做等值连接,然后对两个连接的结果做全连接
select t1.c1, t2.c2, t3.c3, t4.c4
from t1, t2, FULL OUTER JOIN( t3,t4)
where t1.c1 = t2.c1
and t3.c1 = t4.c1
and t1.c2 = t3.c2
我在10.0上测试,总是报语法错,达人们帮俺看看
另,10.0的手册上说支持在结果集上进行查询,即: select * from ( select * from t );
但是俺测试了一下,也报语法错,有试过的没?请告诉一下,到底这个sql能不能在10.0上运行啊 表:t1,t2,t3,t4
t1与t2做等值连接,t3,t4做等值连接,然后对两个连接的结果做全连接
select t1.c1, t2 ...
novemberrain 发表于 2011-08-21 20:14 http://bbs.chinaunix.net/images/common/back.gif
select t1.c1, t2.c2, t3.c3, t4.c4
from t1,t2 full outer join t3 on t3.c2=t1.c2
full outer join t4 on t4.c1=t3.c1
where t1.c1=t2.c1
select t1.c1, t2.c2, t3.c3, t4.c4
from t1, t2, OUTER ( t3,outer t4)
where t1.c1 = t2.c1
and t3.c1 = t4.c1
and t1.c2 = t3.c2
select * from (select * from t)在V11能执行,说是DBACCESS的问题,不认识这种语法,需要升级。用ISQL或CSDK试试? select t1.c1, t2.c2, t3.c3, t4.c4
from t1,t2 full outer join t3 on t3.c2=t1.c2
full oute ...
3sane 发表于 2011-08-22 14:51 http://bbs.chinaunix.net/images/common/back.gif
谢谢3sane!
前几天没顾上回,今天说一下测试的情况
第二种方式可以执行,但是结果不对,相当于只做了左连接。按照informix的手册一直没测试成功informix语法的全连接该怎么写,哪位达人知道告诉下,谢谢哈
第一种方式报语法错,我的是informix10.0,不知道是不是版本的原因,改成如下方式,通过,而且结果是全连接
select t1.c1, t2.c2, t3.c3, t4.c4
from t1 inner join t2 on t1.c1 = t2.c1
full outer join ( t3 inner join t4 on t3.c1 = t4.c1 )
on t1.c2 = t3.c2
另,用CSDK3.0 在 informix10.0 上试了一下 select * from (select * from t) 这个语法,还是抱语法错, 估计是10.0的问题了吧
再次感谢 3sane!
还用,好像informix版越来越冷清了.... 这个写法比较怪。
页:
[1]