【问题标题】:simple join sql ambiguous column简单连接sql歧义列
【发布时间】:2015-10-22 03:30:17
【问题描述】:
我收到一个模棱两可的列错误?尽管它们与我选择的所有其他列完全相同。
SELECT DISTINCT [date], [problem], [companyprofit], [fixtime]
FROM [fixandresponse] , [netprofit]
WHERE [fixandresponse].[date] = [netprofit].[date]
【问题讨论】:
标签:
sql
join
where
ambiguous
【解决方案1】:
因为两个表有相同的列名:日期。
你可以试试这个:
SELECT DISTINCT [fixandresponse].[date], [problem], [companyprofit], [fixtime]
FROM [fixandresponse] , [netprofit]
WHERE [fixandresponse].[date] = [netprofit].[date]
另外,你应该使用:
SELECT DISTINCT F.[date], F...., N.... -- get column from two table
FROM [fixandresponse] F
INNER JOIN [netprofit] N
ON F.[date] = N.[date]
【解决方案2】:
这样测试
Select distinct f.date, f.problem, f.companyprofit, f.fixtime
from fixandresponse f, netprofit n
Where f.date = n.date