I am have two tables which I have left joined like so below to show me the pads by id added in descending order which works fine.
SELECT p.* FROM ruj_users_pad
AS p LEFT JOIN ruj_users
AS u ON p.user_id = u.id
WHERE u.status !=0
AND 1
AND p.status = 1
GROUP BY p.added_date
DESC LIMIT 0, 20
However, now I would like to retrieve a third table which also as an 'added_date' column combine it with the previous query to show the new descending order. The data from the third table is a generated from a button when users click to favorite the current item on the pad.
Here is what I have but it is not working.
SELECT p.*,f.added_date FROM ruj_users_pad
AS p LEFT JOIN ruj_users
AS u ON b.user_id=u.id
LEFT JOIN ruj_users_fave
AS f ON f.brag_id = u.id
WHERE u.status !=0
AND 1
AND p.status = 1
GROUP BY f.added_date DESC, b.added_date DESC
LIMIT 0, 20
The result returns the same as the first result. I don't understand what could be wrong. I would like the result to take into consideration that there is an entry in the ruj_users_fave and combine it with the first result to bring the favorited pad to the top.
Help is greatly appreciated.