MySQL'user_id'在where子句中模棱两可的问题 [英] MySQL 'user_id' in where clause is ambiguous problem

查看:97
本文介绍了MySQL'user_id'在where子句中模棱两可的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何纠正我不断从下面的状态为'user_id' in where clause is ambiguous的代码中得到的问题.感谢您的提前帮助.

How can I correct the problem I keep getting from the code below which states 'user_id' in where clause is ambiguous. Thanks for the help in advance.

这是mysql表.

SELECT user.*, user_info.* 
FROM user 
INNER JOIN user_info ON user.user_id = user_info.user_id
WHERE user_id='$user_id'

推荐答案

您只需指定要使用的user_id,因为user_infouser表均具有名为user_id的字段:

You simply need to specify which user_id to use, since both the user_info and user table have a field called user_id:

... WHERE user.user_id='$user_id'

SQL不会容忍这种歧义,因为就其所知,两个字段都可以代表完全不同的数据.

SQL wouldn't tolerate this ambiguity, since for what it knows, both fields can represent totally different data.

这篇关于MySQL'user_id'在where子句中模棱两可的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆