发布于 5年前

MySQL 查询报错 Column 'id' in where clause is ambiguous

多表查询时,发现报错: Column 'id' in where clause is ambiguous。

意思是:列"id"是模棱两可的。

sql语句:

select user.id as uid,info.realname from user left join userinfo on user.id=userinfo.uid where id=1

原来是2张表都有id字段,应该指定是哪一张表的id。如:

select user.id as uid,info.realname from user left join userinfo on user.id=userinfo.uid where user.id=1
©2020 edoou.com   京ICP备16001874号-3