简单连接SQL歧义列



我得到一个模棱两可的列错误?尽管它们与我选择的所有其他列完全相同。

SELECT DISTINCT [date], [problem], [companyprofit], [fixtime]
FROM [fixandresponse]  , [netprofit] 
WHERE [fixandresponse].[date] = [netprofit].[date]

因为两个表有相同的列名:date.

你可以试试:

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]

Thus Test

Select distinct f.date, f.problem, f.companyprofit, f.fixtime    
from fixandresponse f, netprofit n    
Where f.date = n.date