Home > database > A random access database data, with the WHERE condition
A random access database data, with the WHERE condition
Time:10-23
The following link is to find information, to the didn't add the where query condition! https://blog.csdn.net/c_staunch/article/details/84428904 SELECT * FROM table_name as t1 WHERE t1. Id>=RAND () * (SELECT MAX (id) FROM table_name)) LIMIT 1; This statement is how to add the where condition, tried many times are not
CodePudding user response:
Efficiency of a way: Select * from table_name The where condition The order by the rand () limit 1
CodePudding user response:
A good efficiency:
select * from table_name where col1=XXX And id>=rand () * (SELECT Max (id) FROM table_name WHERE col1=XXX) limit 1;
Remember the query condition index,
CodePudding user response:
Have a look at this, it is estimated that can help you, https://blog.csdn.net/AHUA1001/article/details/103126626