+ 1

# joint sql

Please help me to solve the query with joint There are two different table, one is for students, and the other is for teacher. I would select students I’d, first name, last name, teacherid from students table. However I need to select each corresponding teacher's last name from teachers table instead of teachers id select students.id,students.firstname, students.lastname, students.teacherid as teacher from students …..how should I write more?

15th Jun 2021, 4:09 PM
YokoS
3 ответов
+ 2
Go over the relevant sections of the SQL course again. They start at 18.1.
15th Jun 2021, 4:44 PM
Simon Sauter
Simon Sauter - avatar
+ 4
I didn't get the schema properly from your question. but see if any of these below are one which you are looking for. Select students.id, students.firstname, students.lastname, teacher.name from student,teacher where students.teacherid=teachers.id; (OR) Select students.id, students.firstname, students.lastname, teacher.id, teacher.lastname from student,teacher;
15th Jun 2021, 4:48 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 1
Thank you for the answer. Your first suggestion worked :)
16th Jun 2021, 6:02 AM
YokoS