Zandis Murāns Posted March 7, 2008 Report Share Posted March 7, 2008 Šis gan saistīts tikai ar mysql, bet klausieties. Kā izveidot jaunu kolonnu rindām, kura satur kaut kādu skaitli, kurš ir par viens lielāks nekā iepriekšējā rindā? Es gribu sekojošo panākt: select augosais_skaitlis() as id, vards from lietotaji where izdzests=false; Tabulā lietotaji (uid,vards,izdzests) glabājas trīs lietotāji (Jānis,Pēteris,Juris) un visiem ierakstiem laukā "izdzēsts" glabājas vērtība "FALSE", izņemot Pēteri, kuram tajā laukā glabājas vērtība "TRUE", es gribu, lai atgriež sekojošas rindas: id|vards ---------- 1|Jānis 2|Juris Kā? Link to comment Share on other sites More sharing options...
bubu Posted March 7, 2008 Report Share Posted March 7, 2008 Nedari to ar mysql. Dari to php pusē while ciklā, kurā izsauc mysql_fetch_row, palielini vienkārši $i katrā cikla iterācijā. Link to comment Share on other sites More sharing options...
Gints Plivna Posted March 7, 2008 Report Share Posted March 7, 2008 (edited) Tu pats kādu laiku atpakaļ devi atbildi šeit :) Gints Plivna http://datubazes.wordpress.com Edited March 7, 2008 by Gints Plivna Link to comment Share on other sites More sharing options...
Zandis Murāns Posted March 7, 2008 Author Report Share Posted March 7, 2008 Nē, tu sit mani nost, bet man vajag to ar mysql. Link to comment Share on other sites More sharing options...
bubu Posted March 7, 2008 Report Share Posted March 7, 2008 Nu tad skaties Ginta linku. Bet imho tev pašam būs tikai vieglāk, ja to nedarīsi ar mysql. Link to comment Share on other sites More sharing options...
Aleksejs Posted March 7, 2008 Report Share Posted March 7, 2008 Skaties šo: http://dev.mysql.com/doc/refman/5.0/en/user-variables.html Tur tieši šie caunteri tiek apskatīti. Link to comment Share on other sites More sharing options...
Zandis Murāns Posted March 7, 2008 Author Report Share Posted March 7, 2008 set @id=0; select (select @id:=@id+1) as id, vards from lietotaji where izdzests=false; Iet, bet kā izskatās? Link to comment Share on other sites More sharing options...
andrisp Posted March 7, 2008 Report Share Posted March 7, 2008 (edited) Pietiktu vienkārši šitā: set @id=0; select @id := @id + 1 as id, vards from lietotaji where izdzests=false; Edited March 7, 2008 by andrisp Link to comment Share on other sites More sharing options...
Zandis Murāns Posted March 7, 2008 Author Report Share Posted March 7, 2008 Bet zinkas ira? Tev ir absolūta taisnība, haha. Link to comment Share on other sites More sharing options...
Recommended Posts