免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4057 | 回复: 8
打印 上一主题 下一主题

SQL 中的right join 在DB2/400中能用吗 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-30 12:37 |只看该作者 |倒序浏览
在DB2/400交互SQL中使用 right join却说right无效,right join 在DB2/400中能用吗

论坛徽章:
0
2 [报告]
发表于 2007-10-30 12:55 |只看该作者
我测试了,可以的

> select *                        
   from pc01 right join pc09      
   on pc01.porno=pc09.porno        
   SELECT statement run complete.

论坛徽章:
0
3 [报告]
发表于 2007-10-30 13:00 |只看该作者
但运行后是 "Token RIGHT was not valid. Valid tokens: FOR WITH ORDER UNION OPTIMI ",什么原因?

论坛徽章:
0
4 [报告]
发表于 2007-10-30 13:52 |只看该作者
把你完整语句以及运行后提示贴出啦,有图最好拉

顺便说下我运行主机为v5r3,怀疑是否你的版本较低

论坛徽章:
0
5 [报告]
发表于 2007-10-30 14:16 |只看该作者
select *                                                            
from test02 a right outer join test01 b                     
on (a.id_no=b.id_no)                                             
Token RIGHT was not valid. Valid tokens: FOR WITH ORDER UNION OPTIMI
版本:v4r3

论坛徽章:
0
6 [报告]
发表于 2007-10-30 14:20 |只看该作者
select *                                                            
from test02 a right join test01 b                     
on (a.id_no=b.id_no)                                             
Token RIGHT was not valid. Valid tokens: FOR WITH ORDER UNION OPTIMI
版本:v4r3

论坛徽章:
0
7 [报告]
发表于 2007-10-30 15:43 |只看该作者
这个是V5R3官方得例子,我以前用过,是好用得

Right Outer Join
A right outer join will return all the rows that an inner join returns plus one row for each of the other rows in the second table that did not have a match in the first table. It is the same as a left outer join with the tables specified in the opposite order.

The query that was used as the left outer join example can be rewritten as a right outer join as follows:

  SELECT EMPNO, LASTNAME, PROJNO
    FROM CORPDATA.PROJECT RIGHT OUTER JOIN CORPDATA.EMPLOYEE
          ON EMPNO = RESPEMP
    WHERE LASTNAME > 'S'
The results of this query are identical to the results from the left outer join query.

论坛徽章:
0
8 [报告]
发表于 2007-10-31 12:23 |只看该作者
应该是可以的,如果不行,把两个表调换下,再用LEFT JOIN

论坛徽章:
0
9 [报告]
发表于 2007-11-14 10:00 |只看该作者
left join:
SELECT A.fld1, IfNULL(B.fld2,'no') FROM filea A LEFT JOIN
fileb B ON A.fld1 = B.fld2               

5.4 4.5 均OK
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP