天天看點

錯誤:Column 'Id' in field list is ambiguous

錯誤的SQL代碼

SELECT Id 
FROM Weather AS W1, Weather AS W2
WHERE W1.Id-W2.Id=1 AND W1.Temperature>W2.Temperature
           

錯誤原因:SELECT Id的時候沒有指定是W1表還是W2表,導緻指代不明

修改之後為

SELECT W1.Id 
FROM Weather AS W1, Weather AS W2
WHERE W1.Id-W2.Id=1 AND W1.Temperature>W2.Temperature
           

繼續閱讀