我有以下疑問:結合兩個查詢 - 如何?
查詢1:
Select * from T10,T11,T12,T13,T14
where T10.C0 = T11.C0 and T11.C1 = T12.C0
and T12.C1 = T13.C0 and T13.C1 = T14.C0;
查詢2:
Select * from T20,T21,T22,T23,T24
where T20.C0 = T21.C0 and T21.C1 = T22.C0
and T22.C1 = T23.C0 and T23.C1 = T24.C0;
我如何可以結合這2次的查詢,以顯示這些表的所有值?我想要加入T10.C1 = T20.C1
。
當試圖union
我得到一個關於不具有相同的列數,這是真正的警告,這些表是不一樣的
工會
Select * from
"ProductConfig","Board","PcbBuild","Model","TcssCalib"
where "Model"."idModel" = "PcbBuild"."Model" and "Board"."PcbBuild" = "PcbBuild"."idPcbBuild"
and "Board"."idBoard" = "TcssCalib"."Board" and "ProductConfig"."TcssCalib" = "TcssCalib"."idTcssCalib"
union
Select * from"ProductBuild","TxResultsLink","TxResults","DspValues" where "ProductBuild"."idProductBuild"
= "TxResultsLink"."ProductBuild" and "TxResults"."idTxResults" = "TxResultsLink"."TxResults"
and "TxResults"."DspValues" = "DspValues"."idDspValues";
在這裏,我想ProductBuild.Productconfig加入ProductConfig.idProductConfig
給出錯誤:
[錯誤]錯誤:每個UNION查詢必須有相同數量的列
的當我嘗試inner join
我在或接近inner
出現語法錯誤有沒有辦法加入這些2查詢在一起?
A JOIN是要走的路。發佈您的JOIN查詢代碼,以便我們可以幫助調試它。另外,我希望這些是混淆的列名稱。 – 2012-01-17 13:47:43
是的,這些是'組成'表和列的名稱(otherwize他們會變得不可讀,我認爲) – Moonlight 2012-01-17 13:49:14