How to implement database Join Association in Mnesia?

Hi, Iam just wondering how to implement Mnesia tables join association efficiently, in other terms I want to know how to implement Nested SQL queries in Mnesia, for example consider we have 3 tables : Person(id, name) , Car(id, color) and Drive(id_person, id_car), and the query is to get the Names of Persons that Drive Black Cars, in SQL Database the Nested Query is as follows :

FROM Person
WHERE id in (SELECT id_person
                         FROM Drive
                         WHERE id_car in (SELECT id
                                                         FROM car
                                                         WHERE color = black))

so my question is how to do that with Mnesia functions (read, select, foldl,…) not with QLC ? I will be thankful for any help.

1 Like