我可以請您幫我將這個 {oj } SQL 語法轉換為正常的連線語法嗎?
SELECT ... FROM {oj (((((((((("VMPH" "VMPH" LEFT OUTER JOIN "VMPT" "VMPT" ON "VMPH"."NMPSTID"="VMPT"."NMPSTID") LEFT OUTER JOIN "ARRTA" "ARRTA" ON "VMPH"."TXTERM"="ARRTA"."CODETERM") LEFT OUTER JOIN "VMAGRE" "VMAGRE" ON "VMPH"."NMAGRE"="VMAGRE"."NMDOCID") LEFT OUTER JOIN "VMDH" "VMDH" ON "VMPH"."NMDOCID"="VMDH"."NMDOCID") LEFT OUTER JOIN "VMPTIT" "VMPTIT" ON ("VMPT"."NMPSTID"="VMPTIT"."NMPSTID") AND ("VMPT"."WDTRANNUM"="VMPTIT"."WDTRANNUM")) LEFT OUTER JOIN "VMPTSV" "VMPTSV" ON ("VMPT"."NMPSTID"="VMPTSV"."NMPSTID") AND ("VMPT"."WDTRANNUM"="VMPTSV"."WDTRANNUM")) LEFT OUTER JOIN "VMPTEQ" "VMPTEQ" ON ("VMPT"."NMPSTID"="VMPTEQ"."NMPSTID") AND ("VMPT"."WDTRANNUM"="VMPTEQ"."WDTRANNUM")) LEFT OUTER JOIN "VMDTEQ" "VMDTEQ" ON ("VMPT"."NMDOCID"="VMDTEQ"."NMDOCID") AND ("VMPT"."WDDTTRNUM"="VMDTEQ"."WDTRANNUM")) LEFT OUTER JOIN "VMMTRM" "VMMTRM" ON ("VMPTEQ"."TXEQUP"="VMMTRM"."TXEQUP") AND ("VMPTEQ"."TXMETER"="VMMTRM"."TXMETER")) LEFT OUTER JOIN "VMEQUP" "VMEQUP" ON ("VMPTEQ"."TXEQUP"="VMEQUP"."TXEQUP")) LEFT OUTER JOIN "VMSERV" "VMSERV" ON ("VMPTSV"."WDSERVTYPE"="VMSERV"."WDTYPE") AND ("VMPTSV"."TXSERV"="VMSERV"."TXSERV")}
我嘗試刪除括號和“oj”,但它不起作用。我嘗試了下面這個,但效果不佳
SELECT ... WHERE "VMPH"."NMPSTID" = "VMPT"."NMPSTID" AND "VMPH"."TXTERM" = "ARRTA"."CODETERM" AND "VMPH"."NMAGRE" = "VMAGRE"."NMDOCID" AND "VMPH"."NMDOCID" = "VMDH"."NMDOCID" AND (("VMPT"."NMPSTID" = "VMPTIT"."NMPSTID") AND ("VMPT"."WDTRANNUM" = "VMPTIT"."WDTRANNUM")) AND (("VMPT"."NMPSTID" = "VMPTSV"."NMPSTID") AND ("VMPT"."WDTRANNUM" = "VMPTSV"."WDTRANNUM")) AND (("VMPT"."NMPSTID"="VMPTEQ"."NMPSTID") AND ("VMPT"."WDTRANNUM"="VMPTEQ"."WDTRANNUM")) AND (("VMPT"."NMDOCID"="VMDTEQ"."NMDOCID") AND ("VMPT"."WDDTTRNUM"="VMDTEQ"."WDTRANNUM")) AND (("VMPTEQ"."TXEQUP"="VMMTRM"."TXEQUP") AND ("VMPTEQ"."TXMETER"="VMMTRM"."TXMETER")) AND "VMPTEQ"."TXEQUP" = "VMEQUP"."TXEQUP" AND (("VMPTSV"."WDSERVTYPE"="VMSERV"."WDTYPE") AND ("VMPTSV"."TXSERV"="VMSERV"."TXSERV"))
P粉6620895212023-09-07 22:39:52
在 mysql 中,如果標識符(即表名、列名)是保留字,則必須用反引號括起來,而您的識別符都不是,因此可能會丟失雙引號。另外 oj (無論是什麼)分配的別名並不是特別有用,所以我會失去這些別名和括號。例如
SELECT * FROM VMPH LEFT OUTER JOIN VMPT ON VMPH.NMPSTID=VMPT.NMPSTID LEFT OUTER JOIN ARRTA ON VMPH.TXTERM=ARRTA.CODETERM LEFT OUTER JOIN VMAGRE ON VMPH.NMAGRE=VMAGRE.NMDOCID LEFT OUTER JOIN VMDH ON VMPH.NMDOCID=VMDH.NMDOCID LEFT OUTER JOIN VMPTIT ON VMPT.NMPSTID=VMPTIT.NMPSTID AND VMPT.WDTRANNUM=VMPTIT.WDTRANNUM LEFT OUTER JOIN VMPTSV ON VMPT.NMPSTID=VMPTSV.NMPSTID AND VMPT.WDTRANNUM=VMPTSV.WDTRANNUM LEFT OUTER JOIN VMPTEQ ON VMPT.NMPSTID=VMPTEQ.NMPSTID AND VMPT.WDTRANNUM=VMPTEQ.WDTRANNUM LEFT OUTER JOIN VMDTEQ ON VMPT.NMDOCID=VMDTEQ.NMDOCID AND VMPT.WDDTTRNUM=VMDTEQ.WDTRANNUM LEFT OUTER JOIN VMMTRM ON VMPTEQ.TXEQUP=VMMTRM.TXEQUP AND VMPTEQ.TXMETER=VMMTRM.TXMETER LEFT OUTER JOIN VMEQUP ON VMPTEQ.TXEQUP=VMEQUP.TXEQUP LEFT OUTER JOIN VMSERV ON VMPTSV.WDSERVTYPE=VMSERV.WDTYPE AND VMPTSV.TXSERV=VMSERV.TXSERV;
還有問題嗎?新增所有表定義。