程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SyBase數據庫 >> SyBase教程 >> sybase有多個left join 和多個union會報錯

sybase有多個left join 和多個union會報錯

編輯:SyBase教程

報錯內容: Adaptive Server cannot perform the requested action because column 'organId' is not within the scope of the joined table expression.Check your command for missing or incorrect database objects,variable names, and/or input data.   select ... from t1 left join t2 on t1=t2 left join ( select ... from t3 union all select ... from t4 )t5 on t1=t5 這樣寫會報錯。 原因 :Hi, it was a limatation of Sybase in the end when using ANSI sql or at least thats what the DBA's told me. A derived table is seen as an inline view in the SQL BO generates, Sybase can handle that but if the inline view contains a union (so your derived table has a union) and there are 3 or more other tables joined with the SQL it throws this error, works fine if only two tables, or if you break the union up into two derived tables. In the end I created the view on the db. I find Sybase frustrating no decode no MINUS commands     Thanks (出自:http://www.forumtopics.com/busobj/viewtopic.php?p=442226) 解決方法:t1和t2聯合,t1和t5聯合,t5是一個union這樣會報錯。把t1和t2先聯合之後在於t5聯合 select t1.* from (select ... from t1 left join t2 on ... ) t6 left join ( select ... from t3 union all select ... from t4 )t5 on t6=t5  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved