Untitled

mail@pastecode.io avatar
unknown
sql
2 years ago
577 B
2
Indexable
Never
INSERT INTO teacher(name, surname, sex, subject) VALUES('natela', 'archvadze', 'qali', 'matematika');
INSERT INTO teacher(name, surname, sex, subject) VALUES('mzia', 'mordebade', 'qali', 'fizika');

INSERT INTO pupil(name, surname, sex, class) VALUES('giorgi', 'varazashvili', 'kaci', 12);

INSERT INTO teacher_pupil(teacher_id, pupil_id) VALUES(1, 1);
INSERT INTO teacher_pupil(teacher_id, pupil_id) VALUES(2, 1);

SELECT t.name
FROM pupil p
    JOIN teacher_pupil tp ON (p.pupil_id = tp.pupil_id)
    JOIN teacher t ON (tp.teacher_id = t.teacher_id)
WHERE p.name = 'giorgi';