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

相关文章:

  • 2021-08-18
  • 2021-06-11
  • 2022-12-23
  • 2022-01-04
  • 2021-08-06
  • 2021-10-16
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
相关资源
相似解决方案