Lets say I have the following table:
| name | category |
----------------------
| Apple | fruit |
| Banana | fruit |
| Orange | fruit |
| Pear | fruit |
| Tomato | vegetable |
| Pepper | vegetable |
| Walnut | nut |
| Cashew | nut |
How do I get results to order in bulks with only one row from category, but then repeat with the rest like so: fruit, vegetable, nut, fruit, vegetable, nut, fruit, vegetable... and so on. I want to achieve this result:
| name | category |
---------------------
| Apple | fruit | ─┐
| Tomato | vegetable | ─├ Bulk 1
| Walnut | nut | ─┘
| Banana | fruit | ─┐
| Pepper | vegetable | ─├ Bulk 2
| Cashew | nut | ─┘
| Orange | fruit | ── Bulk 3
| Pear | fruit | ── Bulk 4
Each time my query will be different but I would like to have the same ordering for the results. Bulks don't have to contain all of the categories (ex. Bulk 3 & 4 contain only one row).
Can this be achieved with a single query/PDO transaction?