0

我试图从具有相同列的 2 个表中进行选择,但两个表都有一个内部连接 ​​-

select e.ID, 
    c.FullName, 
    car.VIN, 
    car.Registration, 
    e.Telephone, 
    e.Mobile, 
    e.Email, 
    e.EstimateTotal, 
    e.LastUpdated, 
    e.LastUpdateBy from (select id from Estimates UNION ALL select id from PrivateEstimates) e

inner join Customers c on c.ID = e.CustomerID
inner join Cars car on car.ID = e.CarID
where e.Status = 0

问题是,在inner join上找不到e.CustomerID、e.CarID或e.Status?有任何想法吗?

4

1 回答 1

3

你的子查询

select id from Estimates 
union all
select id from PrivateEstimates

仅返回一id列。如果要在JOIN语句中使用这些列,请在子查询中包含必要的列

于 2013-07-03T10:32:22.210 回答