mysql错误:Column ‘id’ in field list is ambiguous

1、错误信息

ERROR 1052 (23000): Column 'id' in field list is ambiguous

2、原因分析

列’ID’在字段列表中重复,其实就是两张表有相同的字段,但是使用时表字段的名称前没有加表名,导致指代不明,前面加上前缀student就没问题了。

3、解决方案

SELECT student.name, student.student_id, score.score FROM student INNER JOIN score ONstudent.student_id = score.student_id WHERE student.name='mio';

+------+------------+-------+

| name | student_id | score |

+------+------------+-------+

| mio  |          1 |    99 |

| mio  |          1 |    77 |

| mio  |          1 |    88 |

| mio  |          1 |    99 |

+------+------------+-------+

4 rows in set (0.00 sec)

关注我的技术公众号《漫谈人工智能》,每天推送优质文章

mysql错误:Column ‘id’ in field list is ambiguous_第1张图片

你可能感兴趣的:(mybatis,mysql)