Let's say I have the following 4 tables (for example): Owners, Trucks, Crates, Apples.
An owner can have many trucks, a truck can have many boxes, and a box can have many apples.
Owners have an identifier. Trucks have an identifier and owner_id. Boxes have id and truck_id. Apples have id and box_id.
Say I want all the apples to “belong” to the owner with id = 34. Therefore, I want to get all the apples that are in the boxes that are in the trucks owned by the owner 34.
There is a “hierarchy” if you make 4 tables, each of which has a link only to its “parent”. How can I quickly filter fields when conditions are met in the other three tables?
Hope this made some sense.
Thanks.
source share