I need some SQL help... This aint working out for me...
SELECT * FROM {clan_members} cm
LEFT JOIN {clan_ranks} r ON r.rid=cm.rid
LEFT JOIN {users} u ON u.uid=cm.uid
WHERE cm.ClanID='{$clan->ClanID}' ORDER BY r.rClanID DESC, r.rid DESC, u.name ASC
Basically I need clan_ranks to return any matching ClanID's that match rid, but I need to make it JOIN r.rClanId=0 if r.rClanID is not equal to cm.ClanID.... currently it doesnt work... it returns a ton more rows with bad data (uid's of 0 or null instead of proper ones)....
Any ideas? I'm trying to get it done in 1 query if possible... but will goto 2 if I cant find a better solution... and just ignore the {} around table names, its a Drupal query string.
I've tried about 2hrs of tweaking the query in different ways... nothing got me closer than this, and its still wrong...