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 子句是不明确的问题
基础教程推荐
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 在多列上分布任意行 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
