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可以用来为所查询的数据库表取别名,为表的别名