Randomly draw 3 consecutive records?
As table:
Temid
1
2
3
4
5
6
7
8
If you take 3 records, the result can be:
1
2
3
Or
4
5
6
Or
7
8
1
Or
8
1
2
Wait a minute
Can't figure out how to write MySQL? Is there any good way to use PHP to take random random extraction ? php?mysql
------Solution--------------------
Use rand (1,8) to get a random integer, stored in a 3-length list, if the obtained random integer is the same as before, re-fetch, take 3 different numbers, with these 3 numbers for the ID to the database to fetch records
------Solution--------------------
References: Do
781 and 812 still count as continuous data? You're a ring-shaped list.
SELECT * FROM test as T1 joins (select round (rand () * (select Max (temid) from ' Test ') as ID) as T2
where T1. Temid >= T2. Temid
ORDER by T1. Temid ASC Limi ...
There's a clerical error.
SELECT * FROM test as T1 joins (select round (rand () * (select Max (temid) from ' Test ') as Temid) as T2
where T1.temid >= T2.temid
ORDER BY t1.temid ASC limit 3;