sql server - Sql Query for the following output -
i have 2 tables:
table_1: (name, street, city) table_2: (name, teacher_name)
the column name in table_1 contains student's name teacher's name while in table_2 column name contains student's name , teacher_name contains teacher's name corresponding student.
so question sql query finding students live in same street , city teachers.
please , in advance.
you need join table_1 twice. so:
select students.name, teachers.name table_2 teacher_student join table_1 students on students.name = teacher_student.name join table_1 teachers on teachers.name = teacher_student.teacher_name students.street = teachers.street , students.city = teachers.city
Comments
Post a Comment