Order hybrid mixed mysql search result in one query?
Posted
by Fredrik
on Stack Overflow
See other posts from Stack Overflow
or by Fredrik
Published on 2010-04-19T11:28:04Z
Indexed on
2010/04/19
11:33 UTC
Read the original article
Hit count: 327
This problem is easy fixed clientside. But for performance I want to do it directly to the database.
LIST a
+------+-------+-------+
| name | score | cre |
+------+-------+-------+
| Abe | 3 | 1 |
| Zoe | 5 | 2 |
| Mye | 1 | 3 |
| Joe | 3 | 4 |
Want to retrieve a joined hybrid result without duplications.
Zoe (1st higest score)
Joe (1st last submitted)
Abe (2nd highest score)
Mye (2nd last submitted)
...
Clientside i take each search by itself and step though them. but on 100.000+ its getting awkward. To be able to use the LIMIT function would ease things up a lot!
SELECT name FROM a ORDER BY score DESC, cre DESC;
SELECT name FROM a ORDER BY cre DESC, score DESC;
© Stack Overflow or respective owner