I need to join with last record of "purchased_products" table to get the latest actual balance.
SELECT * FROM {users} u
LEFT JOIN {role_expire} re ON u.uid=re.uid
LEFT JOIN {purchased_products} pp ON re.uid=pp.uid
WHERE (re.expire <= NOW() OR re.expire is NULL) || (pp.balance < 0 OR pp.balance IS NULL)
What is the best way to that?








Bookmarks