_siikais_ Posted November 26, 2007 Report Share Posted November 26, 2007 respektiivi: $query2 = mysql_query("select * from [table] where [category]='$q' ORDER BY Name"); while ($results=mysql_fetch_array($query2)) { //$i++; echo "$results['Name']<br>"; } Pienjemsim ka $q ir 1 un liidz ar to peec vaicaajuma vinjsh izvada: Manta Manta1 manta2 manta3 manta3 manta4 Kaa izsleegt vienaados textus manta3, taa lai paraadiitos tikai viens no shiem abiem ieraxtiem manta3... Elemenetaaraak runaajot, Ja vinjsh atgriezh ieraxtus peec konkreetaas kategorijas un ja tur ir vairaaki vienaadi texti tad vinjsh izvada nevis visus textus vienaados bet tikai vienu no visiem? Link to comment Share on other sites More sharing options...
Kavacky Posted November 26, 2007 Report Share Posted November 26, 2007 GROUP BY `name` Link to comment Share on other sites More sharing options...
_siikais_ Posted November 26, 2007 Author Report Share Posted November 26, 2007 GROUP BY `name` da ne tur sleepjas fiicha =) grou tikai sagrupee peec konkreetiem textiem bet ne jau to man vajag... ir vajadziiba peec vienaado textu samazinaashanas ja ieksh taas table ir ieraxti ar 3 vienaadiem name tad pie izvades vinjsh tikai izvada 1 un taa ar vieism Link to comment Share on other sites More sharing options...
Dooling Posted November 26, 2007 Report Share Posted November 26, 2007 Vai pareizi sapratu Tavu domu? $query2 = mysql_query("SELECT [b]DISTINCT Name[/b] from [table] where [category]='$q' ORDER BY Name"); while ($results=mysql_fetch_array($query2)) { //$i++; echo "$results['Name']<br>"; } Link to comment Share on other sites More sharing options...
marcis Posted November 26, 2007 Report Share Posted November 26, 2007 (edited) šeit jau gan abi divi varianti strādās vienādi Edited November 26, 2007 by marcis Link to comment Share on other sites More sharing options...
bubu Posted November 26, 2007 Report Share Posted November 26, 2007 GROUP BY grupē kverija rezultātus, pielietojot visām vienā grupā atgrieztajām vērtībām vienu agrēgātfunkciju (SUM, AVG, COUNT, u.t.t.) Dooling pareizi saka - DISTINCT ir jalieto. Link to comment Share on other sites More sharing options...
andrisp Posted November 26, 2007 Report Share Posted November 26, 2007 MySQLā GROUP BY var arī izmantot, lai vienkārši atselektētu unikālās vērtības. Nav obligāti jāizmanto agregātfunkcijas. Link to comment Share on other sites More sharing options...
Delfins Posted November 26, 2007 Report Share Posted November 26, 2007 viņam ir `*` selektā... lidz ar ko nevarēsi iegūt ID, ja viņi tiem vienādajiem ir dažādi. (tie būs vairāki dažādi ieraksti ar vienādu nosaukumu) Link to comment Share on other sites More sharing options...
andrisp Posted November 26, 2007 Report Share Posted November 26, 2007 Tas attiecas gan uz DISTINCT, gan uz GROUP BY. Link to comment Share on other sites More sharing options...
marcis Posted November 26, 2007 Report Share Posted November 26, 2007 Domāju, ka šajā gadījumā ir pilnīgi vienalga, kuru variantu lieto. Tāpat id no katra varianta dabūsi tikai vienu Link to comment Share on other sites More sharing options...
_siikais_ Posted November 26, 2007 Author Report Share Posted November 26, 2007 O liels paldies... Kur biki siikaak var paskatiities par sql fiichaam a to jau kkaadu otro dienu meegjinaju gan chekot sql manuaaljus netaa gan arii meegjinot ar PHP mainiigo pieshkjirshanu, bet viss izraadijaas elementaaraak ^^... Link to comment Share on other sites More sharing options...
andrisp Posted November 26, 2007 Report Share Posted November 26, 2007 Sīkāk par fīčām vari izlasīt tur pat manuālī. Un gūgli var izmantot: galvenais izdomā kā tā lieta būtu aprakstāma angliski, un 99% gadījumu atradīsi atbildi ;) Link to comment Share on other sites More sharing options...
_siikais_ Posted November 26, 2007 Author Report Share Posted November 26, 2007 nu es principaa googlee ieraxtiiju sql tutorial un kaadas 10 lapas izchekoju katru funkciju paarlasiiju, bet nu shitaadu neieveeroju. =) Nee nu protams vinja varbuut vareeja buut bet ljoti siikiem burtiem ieraxtiita , piemeeram 2 shriftaa, taaka nevareejapamaniit =P Link to comment Share on other sites More sharing options...
andrisp Posted November 26, 2007 Report Share Posted November 26, 2007 Nu vajag konkrētāk ierakstīt: http://www.google.lv/search?hl=lv&q=sql+select+unique Link to comment Share on other sites More sharing options...
marcis Posted November 26, 2007 Report Share Posted November 26, 2007 šis nav slikts variants http://php.lv/f/index.php?showtopic=6491 Link to comment Share on other sites More sharing options...
Recommended Posts