天天看点

错误: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
           

继续阅读