【学习笔记】SAP ABAP——OPEN SQL(一)【SELECT语句】
SELECT语句简介
SELECT <lines> <columns> FROM <db> WHERE <condition>
其中代表查询的件数,代表查询的字段名
SELECT SINGLE
SELECT SINGLE <cols> FROM <db> WHERE <condition>
该语句用于从数据库表中查询单条数据
SELECT SEVERAL LINE
SELECT [DISTINCT] <columns> FROM <db> WHERE <condition>
[DISTINCT]为可选项,若选择则自动删除所查询数据的重复项,在本文最后的一个案例代码效果中有演示!!
SELECT并且输出打印的两种方式
1. SELECT…ENDSELECT
REPORT ZWYZTEST_FOR_MANGO.
DATA:GT_SFLIGHT TYPE TABLE OF SFLIGHT.
DATA:GS_SFLIGHT TYPE SFLIGHT.
SELECT * INTO GS_SFLIGHT FROM SFLIGHT WHERE CARRID = 'AC'.
WRITE:/ GS_SFLIGHT-CARRID,GS_SFLIGHT-CONNID.
ENDSELECT.
2.SELECT(LOOP…ENDLOOP)
REPORT ZWYZTEST_FOR_MANGO.
DATA:GT_SFLIGHT TYPE TABLE OF SFLIGHT.
DATA:GS_SFLIGHT TYPE SFLIGHT.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_SFLIGHT FROM SFLIGHT WHERE CARRID = 'AC'.
LOOP AT GT_SFLIGHT INTO GS_SFLIGHT.
WRITE:/ GS_SFLIGHT-CARRID,GS_SFLIGHT-CONNID.
ENDLOOP.
SELECT…AS
SELECT <columns> AS <alias>...
AS可以用来为所查询的数据库表取别名,为表的别名
原文地址:https://blog.csdn.net/czxjlsn/article/details/143565875
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!