n data taken randomly mysql

  1.  SELECT * FROM tableName ORDER BY RAND () LIMIT n small amount of data, then also, data volume up, affecting the performance.
  2. The table ID, assuming there are 1000 data in the table, then the random number to Mr. 1000, such as into the array, and then traverse, and where id = randnum, query cycle n times. I can not think of another way.

Guess you like

Origin www.cnblogs.com/bneglect/p/11324208.html