mysql多表聯合查詢如何返回一張表的內容
今天在使用mysql語句的時候老是報錯,語句如下:
www.2cto.com
Sql代碼
SELECT sapcle FROM SellEnterpriseBaseInfor sebie,SellEnterpriseBaseInforVer sebive,SellApplyPermitChangeList sapcle
WHERE 1=1 AND sebie.iVerID = sebive.id AND sapcle.iEnterpriseBaseInforID=sebive.id AND sapcle.iState=1 AND sapcle.iEnterpriseID=11027516 AND sapcle.id=84
在consol控制台,查詢到hibernate打印出來的sql語句,拿到mysql裡面查詢的時候老是報錯,提示Unknown column 'sapcle' in 'field list',按照後面定義的 SellApplyPermitChangeList sapcle應該已經沒問題了,問了同事才發現,在java語句裡面可以這麼寫,但是在mysql編輯器裡面使用的時候要改成
Sql代碼
SELECT sapcle.* FROM SellEnterpriseBaseInfor sebie,SellEnterpriseBaseInforVer sebive,SellApplyPermitChangeList sapcle
HERE 1=1 AND sebie.iVerID = sebive.id AND sapcle.iEnterpriseBaseInforID=sebive.id AND sapcle.iState=1 AND sapcle.iEnterpriseID=11027516 AND sapcle.id=84