错误代码 1052 Column 'stu id' in field list is ambiguous

Posted odejsjhshw

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误代码 1052 Column 'stu id' in field list is ambiguous相关的知识,希望对你有一定的参考价值。

1、错误描述

 

1 queries executed, 0 success, 1 errors, 0 warnings

查询:select stu_id, (SELECT stu_name FROM t_student_info t WHERE t_student_info.stu_id = t.stu_id) stu_name from t_student_info t, t_...

错误代码: 1052
Column ‘stu_id‘ in field list is ambiguous

执行耗时   : 0 sec
传送时间   : 0 sec
总耗时      : 0 sec

2、错误原因

 

 

SELECT 
  stu_id,
  (SELECT 
    stu_name 
  FROM
    t_student_info t 
  WHERE t_student_info.stu_id = t.stu_id) stu_name
FROM
  t_student_info t,
  t_score_info t0 
WHERE t.`stu_id` = t0.`stu_id` 

 

      无法区别stu_id是属于哪张表,导致模糊不清

 

3、解决办法

 

SELECT
	t0.stu_id,
	(SELECT t.stu_name FROM t_student_info t WHERE t.stu_id = t1.stu_id) stu_name
FROM
	t_student_info t1,
	t_score_info t0
WHERE
	t1.`stu_id` = t0.`stu_id`


再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow





以上是关于错误代码 1052 Column 'stu id' in field list is ambiguous的主要内容,如果未能解决你的问题,请参考以下文章

Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous

1052:字段列表中的列“id”不明确

SQLSTATE [23000]:完整性约束违规:1052 列“created_at”在 order 子句中不明确 Laravel 5.5

错误代码 1366 Incorrect integer value 'zhangsan' for column 'd

Laravel JOIN SQLSTATE [23000] 问题:违反完整性约束:字段列表中的 1052 列“album_id”不明确

django.db.utils.OperationalError:(1052,“字段列表中的列'名称'不明确”)