0

Is there any way to mix mysql result?

For example I have these results in my database table

id  | data
-----------
1   | data 1
2   | data 2
3   | data 3
   ...
N   | data N

And I want the data to be shown in random.

For example

data 1
data 3
data 2
data 6

I hope it was easy to understand me, sorry if something in my question is not clear.

Thank you in advance

user3104718
  • 83
  • 1
  • 9

1 Answers1

1

You can order by RAND with hash that is under your control, also it will reset with each select and also it will eat up much less resources, just add to your SELECT statement ORDER BY MD5( CONCAT( id, CURRENT_TIMESTAMP ) )

Tested it on table that has over 2 mln rows and works like a charm.

LukasS
  • 176
  • 7