stencilz Posted April 10, 2007 Report Share Posted April 10, 2007 skatījos manuālī, bet tā īsti nesaprotu kas ir jāmeklē :( tātad nepieciešams selektot rindu skaitu no tabulas kurām id lauks ir neatkārtojas respektīvi --------- id --------- 2 --------- 2 --------- 1 --------- vajadzētu output būt 2 Link to comment Share on other sites More sharing options...
rpr Posted April 10, 2007 Report Share Posted April 10, 2007 ja buutu papeetijis mysql selekt sintaksi, tad tur ir taads parametrs kaa HAVING peec kura var atlasiit atselekteetaas lietas. Link to comment Share on other sites More sharing options...
cucumber Posted April 10, 2007 Report Share Posted April 10, 2007 select * from group by id? Link to comment Share on other sites More sharing options...
stencilz Posted April 10, 2007 Author Report Share Posted April 10, 2007 ja buutu papeetijis mysql selekt sintaksi, tad tur ir taads parametrs kaa HAVING peec kura var atlasiit atselekteetaas lietas. pētu to HAVING bet nesaprotu, kā to izdarīt Link to comment Share on other sites More sharing options...
Grey_Wolf Posted April 10, 2007 Report Share Posted April 10, 2007 SELECT DISTINCT id FROM tabula Link to comment Share on other sites More sharing options...
stencilz Posted April 10, 2007 Author Report Share Posted April 10, 2007 list($z) = mysql_fetch_row(mysql_query("SELECT DISTINCT id FROM tabule")); man atgriež 29 lai gan tur ir 30 rindas ar trīs unikāliem id Link to comment Share on other sites More sharing options...
bubu Posted April 10, 2007 Report Share Posted April 10, 2007 Esi pārliecināts? Link to comment Share on other sites More sharing options...
stencilz Posted April 11, 2007 Author Report Share Posted April 11, 2007 jā Link to comment Share on other sites More sharing options...
litt Posted April 11, 2007 Report Share Posted April 11, 2007 Ja pareizi saprotu jautājumu, tad select count(1) from (select count(1) c, id from tabula group by id) t where t.c = 1 P.S kverijs uz ātru roku rakstīts, gan jau ir iespējas to nooptimizēt vai pārrakstīt savādāk, bet idejiski kaut kā tā.. Link to comment Share on other sites More sharing options...
stencilz Posted April 11, 2007 Author Report Share Posted April 11, 2007 (edited) šito vispār nesaprotu, kas tas par 1 ? $z = mysql_num_rows(mysql_query("SELECT DISTINCT id FROM referal")); šitā ir ok, tā būs labi? Edited April 11, 2007 by stencilz Link to comment Share on other sites More sharing options...
bubu Posted April 11, 2007 Report Share Posted April 11, 2007 Nē, tā nebūs labi. Tas būs lēni un daudz lieku datu jāpārsūta. Labi būs: SELECT COUNT(DISTINCT id) FROM tabule Link to comment Share on other sites More sharing options...
Grey_Wolf Posted April 11, 2007 Report Share Posted April 11, 2007 (edited) varu piebilst pie bubu teiktaa ka vel vari izmantot aliaas ... AS pseido_nosaukums / tik taads kada nav tabulas strukturaa / SELECT COUNT(DISTINCT id) AS kopejas_skaits FROM tabule un tad varesi skaitu dabuut $row = mysql_fetch_array(mysql_query("SELECT ..... ")); $skaits=$row['skaits_kopaa']; edit : ja neizmanto AS tad tas coun vertiba buus 0 elements ..... $skaits=$row[0];.... Edited April 11, 2007 by Grey_Wolf Link to comment Share on other sites More sharing options...
andrisp Posted April 11, 2007 Report Share Posted April 11, 2007 Man labāk patiktu šādi: list($skaits) = mysq_fetch_row(mysql_query("SELECT COUNT(DISTINCT id) FROM tabule")); Link to comment Share on other sites More sharing options...
Recommended Posts