-1

Im having problems on my sql and dont know how to fix it. Can anyone provide some help and tips for it?

Column 'student_id' in field list is ambiguous

SELECT student_id, student.first_name, student.last_name, subject.label, student_score 
FROM score 
INNER JOIN student as stdtab on stdtab.id = student_id
INNER JOIN subject as stab on stab.id = subject_id
Shadow
  • 33,525
  • 10
  • 51
  • 64
CM2345
  • 1

1 Answers1

1

This error means the student_id column name exists in more then one table in the query, use the table name before student_id. Like this (if student_id is in table student):

SELECT student.student_id, student.first_name, student.last_name, subject.label, student_score 
FROM score 
INNER JOIN student as stdtab on stdtab.id = student.student_id
INNER JOIN subject as stab on stab.id = subject_id
Ibrahim Hamaty
  • 540
  • 2
  • 18