您的位置:首页 > 数据库 > MySQL

使用mysql数据库进行左右连接查询的时候出现错误提示 Column 'id' in where clause is ambiguous

2018-02-02 18:26 751 查看
使用mysql数据库进行左右连接查询的时候出现错误提示 Column 'id' in where clause is ambiguous。

这个错误in where clause is ambiguous多半是因为多表查询的时候几个表中同时出现了某个相同的列名,而在查询条件WHERE后面又没有指定是那个表,而引起的
又或者是查询结果里面有两个相同的列名,而没有指定是哪个表使用的时候可以这样,mysql查询前面加表名可避免出现错误Column 'id' in where clause is ambiguous

 $sql = "select * from (store as a right join area as c on a.area_id=c.id)  left join `group` as
b on a.id=b.store_id where a.area_id=88"; 

where 条件语句后查询某个字段要加上表名
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: