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 子句是不明确的问题
基础教程推荐
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 无法解决整理冲突 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
