我在使用 sql 语句上的函数 concatrelated 时遇到问题。我想获得如下:
我的数据是:
A.CABNRO E01.EXCCEX
90001 500
87000 400
90001 450
90001 300
87000 500
76005
我想获得:
A.CABNRO NEW FIELD
90001 500,450,300
87000 400,500
76005
当我包含与 concatrelated 相关的语句时,以下代码不会运行。如果有人可以帮助我,我将不胜感激!!!
MYSQL = "SELECT A.CABFPR, A.CABCIA, A.CABCTR, B.CTRDTR, A.CABLOE, "
MYSQL = MYSQL & "A.CABNRO, A.CABCAR, A.CABFED, A.CABHOD, A.CABFEI, "
MYSQL = MYSQL & "A.CABHOI, A.CABFEF, A.CABHOF, A.CABFEE, A.CABHOE, "
MYSQL = MYSQL & "A.CABCCL, A.CABNEM, A.CABDEM "
MYSQL = MYSQL & "CONCATRELATED(EXCCEX, E01, A.CABNRO=E01.EXCNRO) "
MYSQL = MYSQL & "FROM BDYOBEL.AIPDTA.AIPCAB A "
MYSQL = MYSQL & "LEFT OUTER JOIN BDYOBEL.AIPDTA.AIPCTR B ON A.CABCIA=B.CTRCIA AND A.CABCTR=B.CTRCTR "
MYSQL = MYSQL & "LEFT OUTER JOIN BDYOBEL.AIPDTA.AIPEXC E01 ON A.CABNRO=E01.EXCNRO "
MYSQL = MYSQL & "WHERE A.CABCIA='LOR' AND A.CABFED>="
MYSQL = MYSQL & Chr$(39) & fini & Chr$(39) & "AND A.CABFED<=" & Chr$(39) & ffin & Chr$(39)
MYSQL = MYSQL & " AND (A.CABCTR='DM' OR A.CABCTR='L1' OR A.CABCTR='L5' OR A.CABCTR='LR') AND A.CABCAR<>'0'"