My Assistant
![]() ![]() |
|
|
Aug 8 2006, 10:29 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 198 |
I'm receiving this The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. (Error 3141) when I try to run the below Union Query.
How can I fix the error? SELECT DISTINCT CHESS_PROD_PO.ITEM, NAME as VName, VENDOR as V Num, LTrim([PO_NUM]) AS poNUM, PO_LINE as POLine, PO_DEL_SCHED_DATE as POSched, USER_DATE as PromDT, MAT_SPEC as PGM, Null as ONum, Null as OLine, Null as RLine, Null as RecDT, Null as agCodes FROM (((CHESS_PROD_PO_DEL INNER JOIN CHESS_PROD_PO_HDR ON (CHESS_PROD_PO_DEL.PO_NUM = CHESS_PROD_PO_HDR.PO_NUM) AND (CHESS_PROD_PO_DEL.PUR_CCN = CHESS_PROD_PO_HDR.PUR_CCN)) INNER JOIN CHESS_PROD_PO ON (CHESS_PROD_PO_DEL.PUR_CCN = CHESS_PROD_PO.PUR_CCN) AND (CHESS_PROD_PO_DEL.PO_NUM = CHESS_PROD_PO.PO_NUM) AND (CHESS_PROD_PO_DEL.PO_LINE = CHESS_PROD_PO.PO_LINE)) INNER JOIN CHESS_PROD_VEN_LOC ON (CHESS_PROD_PO_HDR.VENDOR = CHESS_PROD_VEN_LOC.VENDOR) AND (CHESS_PROD_PO_HDR.PUR_LOC = CHESS_PROD_VEN_LOC.VEN_LOC)) INNER JOIN CHESS_PROD_ITEM ON (CHESS_PROD_PO.ITEM = CHESS_PROD_ITEM.ITEM) AND (CHESS_PROD_PO.REVISION = CHESS_PROD_ITEM.REVISION) WHERE (((CHESS_PROD_VEN_LOC.VEN_LOC)='PUR' Or (CHESS_PROD_VEN_LOC.VEN_LOC)='PUR1' Or (CHESS_PROD_VEN_LOC.VEN_LOC)='PUR2')) UNION ALL SELECT CHESS_PROD_PO.ITEM, Null as VName, Null as V Num, Null as poNUM, Null as POLine, Null as POSched, Null as PromDt, Null as PGM, LTrim([ORDER_NUM]) AS ONum, ORDER_LINE as OLine, REC_LINE as RLine, REC_DATE as RecDT, RTrim([AGC]) AS agCodes FROM CHESS_PROD_PO INNER JOIN (CHESS_PROD_REC_HIST INNER JOIN CHESS_PROD_RECH_HDR ON (CHESS_PROD_REC_HIST.CCN = CHESS_PROD_RECH_HDR.CCN) AND (CHESS_PROD_REC_HIST.MAS_LOC = CHESS_PROD_RECH_HDR.MAS_LOC) AND (CHESS_PROD_REC_HIST.RECEIVER = CHESS_PROD_RECH_HDR.RECEIVER)) ON (CHESS_PROD_PO.ITEM = CHESS_PROD_REC_HIST.ITEM) AND (CHESS_PROD_PO.REVISION = CHESS_PROD_REC_HIST.REVISION) AND (CHESS_PROD_PO.PO_NUM = CHESS_PROD_REC_HIST.ORDER_NUM) AND (CHESS_PROD_PO.PO_LINE = CHESS_PROD_REC_HIST.ORDER_LINE) AND (CHESS_PROD_PO.CCN = CHESS_PROD_REC_HIST.PUR_CCN) WHERE (((CHESS_PROD_RECH_HDR.REC_DATE) Between #7/1/2006# And #7/31/2006# And (CHESS_PROD_RECH_HDR.REC_DATE) Is Not Null) AND ((RTrim([CHESS_PROD_REC_HIST.AGC])) Like "PROP" Or (RTrim([CHESS_PROD_REC_HIST.AGC]))="PRO")) ORDER BY CHESS_PROD_PO.ITEM; |
|
|
|
Aug 8 2006, 10:45 AM
Post
#2
|
|
|
UtterAccess Guru Posts: 946 From: Pennsylvania, USA |
I think NAME is a reserved word...
|
|
|
|
Aug 8 2006, 10:47 AM
Post
#3
|
|
|
UtterAccess Guru Posts: 946 From: Pennsylvania, USA |
Also, I would avoid take out the space in:
Null as V num -> Null AS Vnum |
|
|
|
Aug 8 2006, 10:48 AM
Post
#4
|
|
|
UtterAccess VIP Posts: 894 From: ohio |
At first glance, I bet it doesn't like "V Num", and would recommend [V Num]
hth, Aaron |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 18th June 2013 - 07:28 PM |