cucumber Posted September 10, 2008 Report 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
andrisp Posted September 10, 2008 Report Posted September 10, 2008 Hints: SELECT * FROM (SELECT * FROM table) as tmp_table
Aleksejs Posted September 10, 2008 Report Posted September 10, 2008 SELECT * FROM tabula WHERE id IN (SELECT id FROM tabula ORDER BY id LIMIT 10) ORDER BY RND() LIMIT 4
cucumber Posted September 10, 2008 Author Report 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?
cucumber Posted September 10, 2008 Author Report Posted September 10, 2008 Default engine as of MySQL 3.23 with great performance Viss skaidrs (:
marcis Posted September 11, 2008 Report Posted September 11, 2008 Tak iemet tos pēdējos 10 vienā masīvā un randomā izmet kautkādas 4 vērtības.
cucumber Posted September 11, 2008 Author Report Posted September 11, 2008 ta var, bet gribejas iztikt ar mysql pusi.
Recommended Posts