I have a table that looks like below:
| id | group_id | title |
-------------------------
| 1 | 1 | Hello |
| 2 | 1 | World |
| 3 | 2 | Foo |
| 4 | 2 | Bar |
My query may look like below to return the results above:
SELECT * FROM my_table ORDER BY id
Question
How can I order this table so that the group ids appears to be random, but still the same every time the query is executed.
Possible result example
This result looks to be in a random order. If I run the same query a week later, I want to see the exact same order which means it's not really random.
| id | group_id | title |
-------------------------
| 2 | 1 | World |
| 4 | 2 | Bar |
| 1 | 1 | Hello |
| 3 | 2 | Foo |
- Appears to be random from a group_id perspective. It's no longer ordered by
group_idlike 1 1 2 2, but 1 2 1 2. It could also have been 2 1 1 2 or something that does not increase. - Should return the same results every time, not random each time.
- I could order by title but if a
titleshould change that row will be reordered. So the order needs to be made with theidI guess. - I want to avoid file or database caching if possible.
Is it possible?
Aucun commentaire:
Enregistrer un commentaire