ON子句中的MySQL未知列无法正常工作

时间:2015-07-12 17:38:31

标签: mysql sql

我有这个问题:

select orders.*
      ,customers.name as customername
      ,customers.city as customercity
      ,managers.name as managername
      ,godowns.name as godownname 
from orders
inner join customers 
inner join managers 
inner join godowns on orders.customerid=customers.customerid 
                   and orders.managerid=managers.managerid
                   and orders.godownid=godowns.godownid 
order by orderid desc;

我收到了以下错误:

未知栏' orders.customerid'在' on'

我一直在讨厌这个问题超过一天。它适用于一个系统,而不是另一个系统!

1 个答案:

答案 0 :(得分:1)

select orders.*,customers.name as customername,customers.city as customercity,managers.name as managername,godowns.name as godownname 
from orders 
inner join customers on orders.customerid=customers.customerid 
inner join managers on orders.managerid=managers.managerid 
inner join godowns on orders.godownid=godowns.godownid 
order by orderid desc

每个联接都需要一个on子句