Fetching records using some unknown join I have two tables:

1.  Users
2.  Ratings


Users table have columns i.e. id, name etc.

Ratings table have columns i.e. - id, rate_by_id, rate_to_id etc.

I want to display all the ratings in a table. I can do this very easily with a join but the challenge here is that 2 columns of Ratings table point to Users table and according to me join with only one is possible.

By using which JOIN I can join Ratings table to Users table in a single join query with both the columns (rate_by_id and rate_to_id) have the join with Users table. 



Please add comment if you need any clarification.

Thanks &amp; Regards
I got my answer. Actually I was looking for JOIN SAME TABLE MULTIPLE TIMES which I resolved from here : 


  https://stackoverflow.com/a/12562027/9573341


And for my specific question here is the answer:

SELECT
    ratings.*,
    by_user.id,
    by_user.name,
    by_user.id,
    to_user.name,
FROM
    `rating_table` ratings
LEFT JOIN `users` by_user ON
    ratings.rt_rateBy = by_user.id
LEFT JOIN `users` to_user ON
    ratings.rt_rateTo = to_user.id