Column 'id' in field list is ambiguous

mysql:
问题:Column 'id' in field list is ambiguous
原因:两个表中都有id,它不知道查哪一个表里面的ID。
解决方案:主键的查询须用别名点的方式获取。
定义不同的别名,主键必须用别名标明是哪个表的主键。

select aaa.id diaryId,
userId,
bookId,
type,
content,
video,
videoPic,
viewCount,
likeCount,
commentCount,
recommend,
sss.state,
reward,
sss.nickName,
sss.phone,
createTime
from discovery_diary aaa
left join user sss on sss.id=aaa.userId
where aaa.userId='567' limit 2

原文地址:https://www.cnblogs.com/21heshang/p/7308118.html