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

使用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 条件语句后查询某个字段要加上表名
————————————————
版权声明:本文为CSDN博主「qq_23614619」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_23614619/article/details/79242142

发布了199 篇原创文章 · 获赞 6 · 访问量 8997

猜你喜欢

转载自blog.csdn.net/shujuku____/article/details/105015740