Robis Posted January 25, 2005 Report Share Posted January 25, 2005 Sveiki! Man ir jautajums: Ka lai iegustu veikli no MySQL tabulas, kurai viens lauks piemeram ir `id_kautkads` (var but integer) - ka lai iegustu, cik liela ir lielaka esosha vertiba shim laukam un lai tas numurs butu tikai viens! Iespejams, saprat, ka sheit runa iet par `order` - kartibas skaitljiem, kas datus kartos pec sava veida (nevis id, kuram ir uzlikts auto increment) Link to comment Share on other sites More sharing options...
Venom Posted January 25, 2005 Report Share Posted January 25, 2005 SELECT MAX(lauks) as maximum FROM table sliktāk: SELECT lauks as maximum FROM table ORDER BY lauks DESC LIMIT 1 Link to comment Share on other sites More sharing options...
PheliX Posted January 25, 2005 Report Share Posted January 25, 2005 SELECT MAX(id_kautkads) FROM tabula_kautkada Link to comment Share on other sites More sharing options...
Robis Posted January 25, 2005 Author Report Share Posted January 25, 2005 Atradu pareizo atbildi: SELECT MAX(`lauks`) AS `lauks` FROM `tabula`; Paldies visiem! Tagad nakamais jautajums: :) Ka lai tagad pamainu vinjus vietam, doma tada: Iezimeju konkreta ieraksta `order` lauku! Paskatos, kursh ir tas vienigais istais lauks, kam `order` ir par vienu zemaks (vai augstaks) Samainu vinjiem order ciparus vietam, tb, vienam paaugstinu, otram pazeminu par vienu vai ari otradi! ? Link to comment Share on other sites More sharing options...
Venom Posted January 25, 2005 Report Share Posted January 25, 2005 piem. SELECT MAX() as most ... SELECT MAX() as prev ... WHERE lauks<most LOCK TABLE table WRITE UPDATE table SET lauks=0 WHERE lauks=most UPDATE table SET lauks=$most WHERE lauks=prev UPDATE table SET lauks=$prev WHERE lauks=0 UNLOCK TABLES Link to comment Share on other sites More sharing options...
Recommended Posts