MySQL error: column ‘ID’ in field list is ambiguous

1. Error message

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

2. Cause analysis
Column ‘ID’ is repeated in the field list. In fact, two tables have the same field, but the name of the table field is not preceded by the name of the table, so the reference is unknown. The prefix student is no problem.
3. Solutions

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)

Follow my technical official account “Ramble on ARTIFICIAL Intelligence”, and push high-quality articles every day

Read More: