MySQL #39;user_id#39; in where clause is ambiguous problem(MySQL user_id in where 子句是不明确的问题)
问题描述
如何纠正我从下面的代码中不断得到的问题,其中声明了 where 子句中的 'user_id' 不明确
.提前感谢您的帮助.
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_info
和 user
表有一个名为 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' in where 子句是不明确的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 'user_id' in where 子句是不明确的问题


- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- SQL 临时表问题 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01