Sorting MySQL results within a resultset

Posted by InnateDev on Stack Overflow See other posts from Stack Overflow or by InnateDev
Published on 2010-04-25T14:00:25Z Indexed on 2010/04/25 14:03 UTC
Read the original article Hit count: 337

Filed under:

I have a resultset of lets say 10 results. 3 of them have a type 'Pears', and the next 3 have a type 'Apples' and the next three have a type of 'Bananas'. The last record has a type of 'Squeezing Equipment' - unrelated to the fruits. How do I return this set of results (for pagination too) in a GROUPED order that I specify WITHOUT using any inherent sort factor like ALPHABETA or ID etc? I have the all types at my disposal before running the code so they can be specified. i.e.

ID | Bananas
ID | Bananas
ID | Bananas
ID | Apples
ID | Apples
ID | Apples
ID | Pears
ID | Pears
ID | Pears
ID | Squeezing Equipment

© Stack Overflow or respective owner

Related posts about mysql