I am new to mysql. I Have made a small data base and i need some help for joins.
There are three tables
Now u can see there exists many to many relationship between user and contact table that is one user can have many contacts and one contact can be in the contact list of many users; so for normalization i made a junction table with name user_contact
The problem is i want to fetch username and its all contacts from contact table but i do not how to join these three tables to get data from user table and contact table. Can any write the join query that can solve the problem.
FROM user AS u
JOIN user_contact AS uc
ON uc.user_id = u.user_id
JOIN contact AS c
ON c.contact_id = uc.contact_id