当前位置:网站首页>Opensql quick learning
Opensql quick learning
2022-07-29 03:47:00 【Lunar Yin shortage】
https://www.cnblogs.com/jiangzhengjun/p/4264698.html#_Toc410466920
SELECT , INSERT ,UPDATE , DELETE , MODIFY
SELECT SINGLE … INTO…WHERE/
INNER JOIN ,LEFT OUTER JION Usage restriction
ON The following conditions are similar to WHERE The conditions are similar , But there are the following differences
1. There must be ON Conditional statements , And multiple conditions can only be used AND Connect
2. In each conditional expression , One of the two operands must be from JOIN Right table
3. If it is LEFT OUTER JOIN, Then at least one of the two operands of a conditional expression comes from the left table , One hour comes from the right
4. Out of commission NOT,LIKE,IN( But if it is INNER JOIN, be > , < , BETWEEN … AND , <> You can use )
5. If it is LEFT OUTER JOIN , You can only use the equal sign operator :( = , EQ)
6. If it is LEFT OUTER JOIN , The same right table cannot appear in different LEFT OUTER JOIN Of ON In the conditional expression
7. LEFT OUTER JOIN All fields in the right table of cannot appear in WHERE in
8. If it is LEFT OUTER JOIN, In the same ON In a conditional statement , It can only be associated with the same left table .
A few cases
* Sales order data
SELECT vbeln,bstnk,kunnr,kvgr2 (vbeln Is the sales order number ,bstnk Is the customer reference number ,kunnr Customer code ,kvgr2 For the brand )
FROM vbak
FOR ALL ENTRIES IN @gt_so_inf
WHERE vbeln = @gt_so_inf_vbeln
INTO TABLE @DATA(lt_vbak).
SORT lt_vbak BY vbeln.
among sort The meaning of sorting , think lt_vak With vbeln Default ascending sort for criteria
For all entries in When to use ?
answer :
1. For not join Table of , Use for all entries in Statement concatenates tables in a database table field
for all entries in Similar to external connection , To avoid repeated database queries , Use a field in the inner table as a condition , Get data from database tables ,
If there is one, choose , It is equivalent to filtering data
2. Check whether the inner table is empty , If it is empty , All data will be obtained
3. Out of commission LIKE,BETWEEN and IN( Because these operators are uncertain comparison operators ( Set the selection conditions within a range ))
FOR ALL ENTRIES IN The function of the statement is equivalent to juxtaposing all the selection condition blocks .
ABAP in FOR ALL ENTRIES IN How to use it
stay ABAP In development , Cannot be used for join Or you need to use SELECT Inner table of , We usually use for all entries in Statement concatenates the table with the inner table , Find the required data , for example ; With BSEG Take the aggregation table as an example , as follows :
SELECT bseg~kunnr bseg~lifnr bseg~belnr INTO TABLE itab_bseg FROM bseg FOR ALL ENTRIES IN itab_main
WHERE bukrs in_bukrs and (belnr = itab_main-belnr AND hkont = itab_main-hkont).
because BSEG Unable to join BSIS do inner join So first of all BSIS Put the content in itab_main in , And then use FOR ALL ENTRIES IN To connect
OPENSQL Study
1.SELECT sentence
INTO The result of the statement is not saved to the inner table , When it's a field or structure , Finally, add ENDSELECT sentence , This statement is equivalent to LOOP Loop execution SELECT sentence , Every time you take out a piece of data , Just add it to the structure , Keep reading all qualified data .
*------------- Use structure
* The structure used , Therefore use SELECT ENDSELECT sentence
DATA: gs_zht6 TYPE STANDRAD TABLE OF ZHR_TRAIN_ZHT_1,
gs_zht7 TYPE ZHR_TRAIN_ZHT_1.
SELECT * INTO gs_zht7 FROM ZHR_TRAIN_ZHT_1
WHERE name EQ ' Zhou 0'
WRITE : /gs_zht7-sex,
/gs_zht7-te1.
ENDSELECT.
*------------- Use the inner table
* The internal table is used to save all values at once , So there is no ENDSELECT.
DATA: gs_zht9 TYPE STANDARD TABLE OF ZHR_TRAIN_ZHT_1,
gs_zht8 TYPE ZHR_TRAIN_ZHT_1.
SELECT * INTO TABLE gs_zht9 FROM ZHR_TRAIN_ZHT_1
WHERE name EQ ' Zhou 0'.
LOOP AT gs_zht9 INTO gs_zht8.
WRITE: /gs_zht8-tel,
/gs_zht8-sex.
ENDLOOP.
边栏推荐
- The list is not updated in real time when JS V-for data changes
- Typescript from getting started to mastering (XX) function generics
- 5年多工作经验,工资给15k,要是你,你会接受吗?
- 容斥原理
- 【BGP】小型实验
- Spark dataframe replaces empty characters (or other values) in each column with null
- The difference between int and integer. Is int or integer used in practical applications?
- 内连接和左连接简单案例
- Practical application cases of digital Twins - smart energy
- CUB_ Visualization of key points in 200 bird dataset
猜你喜欢

Violence recursion to dynamic programming 01 (robot movement)

CUB_ Visualization of key points in 200 bird dataset

LVS+KeepAlived高可用部署实战应用

Shopify卖家:EDM营销就要搭配SaleSmartly,轻松搞定转化率

EMD 经验模态分解

(nowcoder22529C)dinner(容斥原理+排列组合)

Cloudera manager platform fault repair record

华为天才少年稚晖君做了一把模块化机械键盘,引起极客圈地震,网友:这才是真正的客制化...

Why BGP server is used in sunflower remote control? Automatic optimal route and high-speed transmission across operators

Since 2019, you must have stopped using this marketing strategy
随机推荐
Remote desktop connection error
1985-2020(8个版次)全球地表覆盖下载与介绍
代码 ~ 隐藏或禁用状态栏和虚拟按键
UCOS task switching process
Since 2019, you must have stopped using this marketing strategy
(2022 Hangdian multi school III) 1002 boss rush (pressure dp+ dichotomy)
Machine learning based on deepchem
容斥原理
关于双指针的思想总结
Let variable declaration feature of ES6 new feature and its case
Raft protocol - process demonstration
I.MX6U-驱动开发-2-LED驱动
座机的表单验证
力扣每日一题-第44天-205. 同构字符串
Deep into C language (1) -- operators and expressions
(newcoder 15079)无关(容斥原理)
Why do programmers so "dislike" the trunk development mode?
"Strangers once met" Summer Street Shen Shuyan_ Xia Mo Shen Shuyan's latest chapter
SQL窗口函数
面试必备!TCP协议经典十五连问!