abap INNER JOIN / left join right join注解
(2017-06-13 11:25:37)| 分类: sap-abap |
开始学abap开发,我花费了一周首先学习数据库。数据库在abap开发中必不可少,alv列表,数据批处理,都是需要对数据库中的表进行操作,把筛选出来的数据显示给最终用户或者添加进数据库。
表1
表2
id_1
name
city
id_2
sex
age
1
jone
chicago
2
M
20
2
tom
singapo
1
W
22
3
smith
singapo
3
M
10
3
smith
japan
4
W
13
各种join包括 :
1.inner join 内链接
列 select name city sex
age as 表3 from 表1 inner
join 表2
on 表1~id_` = 表2~id_2.
表3
name
city
sex
age
jone
chicage
W
22
tom
chicago
M
20
smith
singapo
M
10
smith
japan
M
10
注:inner join
关键字在表中至少存在一个匹配是返回。即根据连接条件,如果连接两表存在匹配字段,则筛选出来
2 right join (右连接 如表4 ) 和 left join (左连接
如表5)
表4
(right)
表5(left)
sex
age
name
city
name
city
sex
age
M
20
tom
singapo
jone
chicago
W
22
W
22
jone
chicago
tom
singapo
M
20
M
10
smith
singapo
smith
singapo
M
10
M
10
smith
japan
smith
singapo
M
10
W
13
NULL
NULL
3 full join
是关键字只要一方有 则创建如新行 。
总结 :本人写alv报表主要用到的是inner
join,其他的暂时未用到,能够理解即可。
下面就对sql语句中各种join的特点和区别进行详细解释一下。
假如有两表(表很简单,只是能说明问题):
为理解方便,位置按在原表中位置显示
left 和right join 其实是在创建新表时以谁为主,inner join
是 关键字双方都存在, left join 是右表关键字和左表比较如果存在,则连接到左表上
right 相同。

加载中…