i have this sql query:
SELECT b.topbid, b.topdate, a.*
FROM auction_items a
LEFT JOIN
(SELECT itemID, MAX(bid) as topbid,
MAX(date) as topdate FROM auction_bids GROUP BY itemID ) b
ON a.id = b.itemID
ORDER BY b.topdate DESC, a.date DESC LIMIT 20
It’s not ordering how i’d like it to. I want it to order by merging b.topdate and a.date.
What is wrong?
You cannot have it order by both b.topdate and a.date, because they could both have a value. If you can say that when they both have a value that you should use one over the other (for instance topdate over date), you can do it like this:
Note the order by. If its the other way around, make it COALESCE(a.date, b.topdate)