Linked Questions
11 questions linked to/from creating a random number using MYSQL
427
votes
21
answers
560k
views
How do I generate a random number for each row in a T-SQL select?
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 ...
5
votes
3
answers
5k
views
mysql - how to get a random time (not date) between two time ranges
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 ...
3
votes
5
answers
2k
views
Select a Random row in realm table
I want to select a random row from the realm table. Something like -
SELECT * FROM table ORDER BY RANDOM() LIMIT 1;
0
votes
4
answers
2k
views
Get random number between 65 to 122
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.
...
1
vote
3
answers
978
views
How come RAND() is messing up in SQL subquery?
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 ...
-4
votes
1
answer
234
views
What do you think of my table in mysql workbench ? Link table?
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 ...
-1
votes
2
answers
100
views
How to update multiple random entries in one column at once in mysql?
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 ...
-2
votes
2
answers
129
views
In SQL, any way to create SELECT for arbitrary numbers?
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 ...
0
votes
1
answer
86
views
How to update rand number in sql
I want to update rand number Resolve this my problem
update abc set postion=rand() where status = 1
Anybody can help
1
vote
1
answer
59
views
Add a random value to an existing column in mysql and return it
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 ...
1
vote
1
answer
47
views
MySQL lookup based on round(1 + rand() * x) produces NULL and multiple results
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 ...