Lets say I have 4 tables A,B,C,D with records and datetime field in each table.
Currently Im using UNION ALL and ORDER BY Date DESC.
The problem is if a table A has 10 records added today, and table B has 10 records added yesterday then the first 10 results are all from table A.
Is it possible to get records ordered by date, but mix them between all 4 tables?
First record will be the latest added from table A, then the latest added from table B, then C, then D. And cycle them like that?
thanks
Unfortunately, MySQL doesn’t have a ranking function – but you can simulate it with variables. I suggest trying something like the following:
Alternatively, try something like: