Linked Questions

427 votes
21 answers
560k views

I need a different random number for each row in my table. The following seemingly obvious code uses the same random value for each row. SELECT table_name, RAND() magic_number FROM ...
MatthewMartin's user avatar
5 votes
3 answers
5k views

I am trying to work out how to return a random time between 2 time ranges. For example, get a random time between 15:00:00 and 22:00:00 So far, I have - but don't know how to limit it select ...
jagku's user avatar
  • 309
3 votes
5 answers
2k views

I want to select a random row from the realm table. Something like - SELECT * FROM table ORDER BY RANDOM() LIMIT 1;
mihirjoshi's user avatar
  • 12.2k
0 votes
4 answers
2k views

I want to get random number between 65 to 122.I am using this query SELECT (FLOOR(65 + RAND() * 122)); after getting help from this question but it is giving me numbers outside the range of 65-122. ...
Despicable's user avatar
  • 3,997
1 vote
3 answers
978 views

My goal is to select a random business and then with that business' id get all of their advertisements. I am getting unexpected results from my query. The number of advertisement rows returned is ...
Jason Fel's user avatar
  • 991
-4 votes
1 answer
234 views

I'm making a small program in Java and I want if I put the name and the born date in a textfield it will fetch the result of the student in semester and the exam. Below the table I made and I have a ...
stack's user avatar
  • 33
-1 votes
2 answers
100 views

I wish to update the values in column stemp but all must be different and random between 30 and 70. for($i=0;$i<=30;$i++) { $temp= mt_rand(30,70); mysqli_query($con,"UPDATE sensor SET ...
bhishaj's user avatar
  • 39
-2 votes
2 answers
129 views

I would like to have a query with a result like below: 1000 2000 3000 or 1 3 5 so on..I want to control results from lists for instance. SELECT 1 — I know that I can use SELECT like this for one ...
kensuke1984's user avatar
  • 1,013
0 votes
1 answer
86 views

I want to update rand number Resolve this my problem update abc set postion=rand() where status = 1 Anybody can help
pankaj's user avatar
  • 1
1 vote
1 answer
59 views

I am getting a little more involved with mysql and wanted to add a value to an existing value in a column. I have already written the function for this. Previously I used the following function, but ...
Dominik's user avatar
  • 3,582
1 vote
1 answer
47 views

I'm trying to select first names from a lookup table at random in MySQL to build a test dataset. I have a table with 200 first names, genders and a row id going from 1 to 200. Something like this: id ...
zoltansn's user avatar