cucumber Posted September 10, 2008 Report Share Posted September 10, 2008 (edited) Vai ir iespejams, ar mysql palidzibu no tabulas panemt 10 pedejos ierakstus un tad no tiem 10 panmetiem 4 random'a? SELECT * FROM `table` ORDER BY `id` desc limit 10 // pedejie desmit SELECT * FROM `table` ORDER BY RAND() limit 4 // randoms Edited September 10, 2008 by cucumber Link to comment Share on other sites More sharing options...
andrisp Posted September 10, 2008 Report Share Posted September 10, 2008 Hints: SELECT * FROM (SELECT * FROM table) as tmp_table Link to comment Share on other sites More sharing options...
Aleksejs Posted September 10, 2008 Report Share Posted September 10, 2008 SELECT * FROM tabula WHERE id IN (SELECT id FROM tabula ORDER BY id LIMIT 10) ORDER BY RND() LIMIT 4 Link to comment Share on other sites More sharing options...
cucumber Posted September 10, 2008 Author Report Share Posted September 10, 2008 SELECT * FROM tabula WHERE id IN (SELECT id FROM tabula ORDER BY id LIMIT 10) ORDER BY RND() LIMIT 4 Shitos variantus es jau meginaju un "kombineju" , bet neko pratigaku par #1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' nebiju dabujis. ps. Uztaisiju ta ka ar pirmo query uztaisas temp tabula un ar otro query 4 randuma no temp tabulas panem , cik labi ta ir darit? Link to comment Share on other sites More sharing options...
Paulinjsh Posted September 10, 2008 Report Share Posted September 10, 2008 kas par mysql versiju? Link to comment Share on other sites More sharing options...
cucumber Posted September 10, 2008 Author Report Share Posted September 10, 2008 Default engine as of MySQL 3.23 with great performance Viss skaidrs (: Link to comment Share on other sites More sharing options...
marcis Posted September 11, 2008 Report Share Posted September 11, 2008 Tak iemet tos pēdējos 10 vienā masīvā un randomā izmet kautkādas 4 vērtības. Link to comment Share on other sites More sharing options...
cucumber Posted September 11, 2008 Author Report Share Posted September 11, 2008 ta var, bet gribejas iztikt ar mysql pusi. Link to comment Share on other sites More sharing options...
Toms Posted September 11, 2008 Report Share Posted September 11, 2008 Stagnāti! Link to comment Share on other sites More sharing options...
Recommended Posts