SnakeLV Posted March 14, 2008 Report Share Posted March 14, 2008 Tabula, kurā ierakstās dati par SMS. Katrā ierakstā ir kollona ID, kura parāda kuru kodu sūīja. Piem "AUZU PARSLA 2" nu un tad ID ir tas cipars.. Nu tātad es mēginu uztaisīt vaicājumu, lai viņs parādītu TOP sūtīto kodu. Nekādies nevaru izdomāt. It kā no sākuma viņam ir jāsaskaita cik daudz ir vienādu ierakstu (nu ar vienādu id) un tad parādī to, piem, max($id). Kāds? Link to comment Share on other sites More sharing options...
anonīms Posted March 14, 2008 Report Share Posted March 14, 2008 (edited) count(niks) defā jau prasti ID ir auto_increatment un tam nevajadzētu būt vienādam, bet nu, ja ir piemēram mysq_query("SELECT count(parslu_id) FROM visas_parslas") Edited March 14, 2008 by anonīms Link to comment Share on other sites More sharing options...
SnakeLV Posted March 14, 2008 Author Report Share Posted March 14, 2008 (edited) count(niks) Nu nē, viņš paņems visu niks skaitu. Jeb visu ierakstu. Vot piem man ir tādi ID: 1 1 2 2 2 2 5 5 Nu un piemēram viņš saskaita cik ir vienādo 1, cik ir vienādo 2 un cik ir vienādo 5. un tad sanāk, ka visvairāk ir vienādo 2 to attēlos ar max($id). EDIT: man ID nav vajadzīgs auto_increatment. Nu ok, lai labāk saprastu, pieņemsim, ka ID vietā ir prece. :D lol Edited March 14, 2008 by SnakeLV Link to comment Share on other sites More sharing options...
marcis Posted March 14, 2008 Report Share Posted March 14, 2008 SELECT COUNT(something) AS s FROM `table` ORDER BY s DESC Link to comment Share on other sites More sharing options...
SnakeLV Posted March 14, 2008 Author Report Share Posted March 14, 2008 SELECT COUNT(something) AS s FROM `table` ORDER BY s DESC Nope neiet.. VIņs parāda visu ierakstu skaitu. Link to comment Share on other sites More sharing options...
andrisp Posted March 14, 2008 Report Share Posted March 14, 2008 Ja es pareizi sapratu, tad tev vajag ko šādu: SELECT kods, COUNT(*) FROM kodi GROUP BY kods ORDER BY COUNT(*) ASC(vai DESC) LIMI 1 Link to comment Share on other sites More sharing options...
777 Posted March 14, 2008 Report Share Posted March 14, 2008 SELECT COUNT(something) AS s FROM `table` ORDER BY s DESC kam tad AS .... tas ja lielais query ar JOIN tad jaa, kam tad te Link to comment Share on other sites More sharing options...
SnakeLV Posted March 14, 2008 Author Report Share Posted March 14, 2008 Ja es pareizi sapratu, tad tev vajag ko šādu: SELECT kods, COUNT(*) FROM kodi GROUP BY kods ORDER BY COUNT(*) ASC(vai DESC) LIMI 1 Tieši mērķī ;) Liels paldies Link to comment Share on other sites More sharing options...
andrisp Posted March 14, 2008 Report Share Posted March 14, 2008 777, ORDER BY Link to comment Share on other sites More sharing options...
777 Posted March 14, 2008 Report Share Posted March 14, 2008 ups, nepamaniju :) tiko no trenina nesen atbraucu, uz atro iegaju apskatities :) nebiju pamanijis ... tnx par korekciju Link to comment Share on other sites More sharing options...
Recommended Posts