Tukar {oj } pertanyaan SQL kepada sintaks SQL biasa
P粉030479054
P粉030479054 2023-09-07 00:20:45
0
1
654

Bolehkah saya meminta anda membantu saya menukar sintaks SQL {oj} ini kepada sintaks gabungan biasa?

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")}

Saya cuba tanggalkan kurungan dan "oj" tetapi tidak berkesan. Saya mencuba yang berikut tetapi ia tidak berfungsi dengan baik

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粉030479054
P粉030479054

membalas semua(1)
P粉662089521

Dalam mysql, jika pengecam (iaitu nama jadual, nama lajur) ialah perkataan yang dikhaskan, ia mesti disertakan dalam tanda belakang, dan nama anda tidak sama, jadi petikan berganda mungkin hilang. Juga alias yang diberikan oleh oj (apa pun ia) tidak begitu berguna, jadi saya akan kehilangan alias dan kurungan tersebut. Contohnya

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;

Sebarang pertanyaan? Tambah semua definisi jadual.

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan