ray Posted October 14, 2006 Report Share Posted October 14, 2006 Man datubāzē ir tabula ar vairākiem laukiem un pilna ar ierakstiem man ar skripta palīdzību vajag izvilkt/attleōt no datubāzes randomā vienas rindas vienu ierakstu pieņemsim "id". kā lai to izdara? Link to comment Share on other sites More sharing options...
ray Posted October 14, 2006 Author Report Share Posted October 14, 2006 Paldies par atsaucību, pats ilgas mocīšanās atradu ;) Link to comment Share on other sites More sharing options...
koko Posted October 14, 2006 Report Share Posted October 14, 2006 Nja... Nekur nav rakstīts mysql dokumentācijā ORDER BY RAND()? http://www.google.lv/search?q=mysql+get+ra...lient=firefox-a jau pirmais ieraksts :D Link to comment Share on other sites More sharing options...
v3rb0 Posted October 14, 2006 Report Share Posted October 14, 2006 * select count(*) from tabula; - vislabāk, ja skaits kaut kur sakešots malā. * php pusē uzmet random ciparu no 0 līdz $tik_cik_ieraksti_tabulā-1 * select * from table limit $cipars_ko_uzmeti,1 būs ātrāk nekā rand() mysql pusē, it sevišķi, ja tabula liela. Link to comment Share on other sites More sharing options...
bubu Posted October 14, 2006 Report Share Posted October 14, 2006 MySQL count(*) jau ļoti ātri izselektē (konstantā laikā), ja vien nelieto InnoDB tabulas (ja nemaldos). Link to comment Share on other sites More sharing options...
Delfins Posted October 15, 2006 Report Share Posted October 15, 2006 vai tad mysql nebija gatavs views ar `rows` fieldu ? Link to comment Share on other sites More sharing options...
Recommended Posts