Lior Lior - 1 year ago 76
SQL Question

Multiple sql joins same table

I have this query:

SELECT,, members.username, b.type, b.amount, FROM b LEFT JOIN members ON b.user_id = WHERE a.something = 1

Now I want to select another
, but now I want it to be by the

How can I achieve that?

vkp vkp
Answer Source

Join the members table with a different alias on the required condition and select the required column from that table.

SELECT,, m1.username, b.type, b.amount, m2.username
LEFT JOIN members m1 ON b.user_id = AND a.something = 1
LEFT JOIN members m2 ON b.other_user_id = 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download