DynamicName Posted July 12, 2006 Report Share Posted July 12, 2006 Vai kāds nevaretu pasvies ideju, ka lai randomā sakārto ierakstus no DB. Link to comment Share on other sites More sharing options...
bubu Posted July 12, 2006 Report Share Posted July 12, 2006 RTFM. http://dev.mysql.com/doc/refman/5.0/en/mat....html#id3083030 http://dev.mysql.com/doc/refman/5.0/en/select.html Pie tam, jau vairākkārt šeit aprunāts jautājums, izmanto search. Link to comment Share on other sites More sharing options...
v3rb0 Posted July 12, 2006 Report Share Posted July 12, 2006 ja liela tabula tad laikam db draudzīgāk esot (vismaz viena ieraksta dabūšanai noteikti): 1. dabū no db ierakstu skaitu. 2. samet N unikālus random ciparus ne lielākus kā ierakstu skaits 3. sataisi un izpildi selectu ( select * from table limit RandomCipari[0], 1 ) union ( select * from table limit RandomCipari[1], 1 ) union ( ... ) union ( select * from table limit RandomCipari[pedējais], 1 } Link to comment Share on other sites More sharing options...
GedroX Posted July 14, 2006 Report Share Posted July 14, 2006 Nu ja ierakstu skaits nepārsniedz dažus tūkstošus, droši var izmantot ORDER BY RAND() LIMIT <vēlamo_ierakstu_skaits>, bet lielām tabulām v3rb0 variants laikam ir labākais. Link to comment Share on other sites More sharing options...
Recommended Posts