Is it possible to set the seed for the RAND () function in MySQL? I need this for unit testing to make sure I know what the expected result is.
In PHP, it is simple:
<?php srand(12345); echo rand(); ?>
In my model, I currently have a query like:
SELECT * FROM table ORDER BY RAND() LIMIT 1;
Now in my unit test, I want to make sure that I know what the seed is for RAND (), so I know which record is returned.
Perhaps by completing an additional request before the request in my model?
I know that I can just add the RAND () argument, but that is not what I want; I do not want to modify the request.
PS. I am using Linux; will this help set the seed for / dev / random, maybe?
source share