JOIN 在ACESS與SQL的不同寫法

2021-07-09 03:54:03 字數 1675 閱讀 9236

多個left join 不在access 和sql的寫法是不同的 如

access

select g.ccbh,g.jyrq,g.[10ib老化後],g.[033ib老化後],g.[05lib老化後],h.[05l02ib老化後] from (select e.ccbh,e.jyrq,e.[10ib老化後],e.[033ib老化後],f.[05lib老化後]  from  

(  select d.ccbh,d.jyrq,d.[10ib老化後],b.[033ib老化後] from 

( select a.ccbh,a.jyrq,c.wcpj as [10ib老化後] from dbcs a  

left join (

select wcpj,jh,jyrq from jbwc where glys ='1.0' and ib='ib'

) c  on a.ccbh=c.jh and format( a.jyrq,'yyyy-mm-dd')=format( c.jyrq,'yyyy-mm-dd')

) d 

left join (

select wcpj as [033ib老化後],jh,jyrq from jbwc where glys ='1.0' and ib='0.033ib'

) b on d.ccbh=b.jh and d.jyrq=b.jyrq

) eleft join (

select wcpj as [05lib老化後],jh,jyrq from jbwc where glys ='0.5l' and ib='ib'

) f on e.ccbh=f.jh and e.jyrq=f.jyrq

) gleft join (

select wcpj as [05l02ib老化後],jh,jyrq from jbwc where glys ='0.5l' and ib='ib'

) hon g.ccbh=h.jh and g.jyrq=h.jyrq

sqlselect a.ccbh,a.jyrq,b.033ib老化後,f.05lib老化後,h.05l02ib老化後,c.wcpj as 10ib老化後 from dbcs a  

left join (

select wcpj,jh,jyrq from jbwc where glys ='1.0' and ib='ib'

) c  on a.ccbh=c.jh and format(a.jyrq,'yyyy-mm-dd')=format(c.jyrq,'yyyy-mm-dd')

left join (

select wcpj as 033ib老化後,jh,jyrq from jbwc where glys ='1.0' and ib='0.033ib'

) b on a.ccbh=b.jh and a.jyrq=b.jyrq

left join (

select wcpj as 05lib老化後,jh,jyrq from jbwc where glys ='0.5l' and ib='ib'

) f on a.ccbh=f.jh and a.jyrq=f.jyrq

left join (

select wcpj as 05l02ib老化後,jh,jyrq from jbwc where glys ='0.5l' and ib='ib'

) h on a.ccbh=h.jh and a.jyrq=h.jyrq 

在ASP中通過SQL訪問ACESS資料庫的方法

1 常量引數的傳遞 假設我們要向資料庫增加一條記錄 張三,男,22,78 02 23,zs 163.net。則變數strsql insert into board username,age,birthday,email values 張三 男 22,78 02 23 這裡我們看到 字串用單引號括起來...

sql語句之union與join的區別

union查詢 使用 union 可以將多個select語句的查詢結果組合起來。語法 select 欄位1,欄位2 from table1 union select 欄位1,欄位2 from table2 例 注意 1 union 關鍵字兩邊的select語句的字段數量是需要一致的,並不要求欄位名稱...

SQL表連線join與union區別

資料庫sql joins就是把來自兩個或多個表的行結合起來。下圖展示了 left join right join inner join outer join 相關的 7 種用法。sql union 操作符合併兩個或多個 select 語句的結果。請注意,union 內部的每個 select 語句必須...