Here are my tables: School
Class
Kid
.
Each class belongs to one school.
Each kid belongs to one class.
All tables have an auto incrementing primary key.
Class
has a foreign key pointing to the school's primary key that it belongs to. Same with Kid
pointing to the primary key of the Class
they belong to.
If I wanted to select kid.id, kid.name, school.id, school.name
how would I do this in one query?
This result would return a record for each kid with their id and name. It would also include their school id and name.
SCHOOL
------
id-primary
eyname
CLASS
-----
id-primary key
school_id-foreign key to school name
KID
---
id-primary key
class_id-foreign key to class name