How to Join three tables with one reference in the query in MySQL