alins Posted October 19, 2004 Report Share Posted October 19, 2004 probleema taada: man ir tabula piemeeram ar diviem 'id' un 'kat' , 'rez' id|kat|rez 1 a 5 2 a 98 3 b 21 4 a 65 5 b 32 6 b 7 a 8 a 9 b utt .. kaa dabuut peedejo ierakstu 'rez' ar 'kat' a kursh nav tuksh (kuram ir kaada veertiiba) un pirmo tuksho 'rez' ar 'kat' a kas ir aiz peedeeja pilnaa ceru ka saprataat Link to comment Share on other sites More sharing options...
Venom Posted October 19, 2004 Report Share Posted October 19, 2004 nē, nesapratām SELECT rez FROM tabula kat='a' AND WHERE rez!='' ORDER BY id DESC LIMIT 1 (ja iekš rez ir NULLes, tad var arī WHERE NOT ISNULL rez) iekš php uzzinām ieraksta ID SELECT rez FROM tabula WHERE kat='a' AND id>$ID ORDER BY id ASC LIMIT 1 ja vajaga ar vienu SELECTu, tad var pamēģināt: (SELECT @ID=id,rez FROM tabula kat='a' AND WHERE rez!='' ORDER BY id DESC LIMIT 1) UNION (SELECT rez FROM tabula WHERE kat='a' AND id>@ID ORDER BY id ASC LIMIT 1) Link to comment Share on other sites More sharing options...
bubu Posted October 19, 2004 Report Share Posted October 19, 2004 Kas ir pēdējais? Relāciju DB ieraksti tabulās nav sakārtoti!! Un kas ir tukšš? NULL vai ""?? Ja tu domāji kārtot pēc ID un lauks lai nav vienāds ar "", tad: pēdējais pilnais: SELECT * FROM tabula WHERE rez!="" ORDER BY id DESC LIMIT 1 pirmais tukšais: SELECT * FROM tabula WHERE rez="" ORDER BY id LIMIT 1 Link to comment Share on other sites More sharing options...
Venom Posted October 19, 2004 Report Share Posted October 19, 2004 Kas ir pēdējais? jautājums bija man? Link to comment Share on other sites More sharing options...
alins Posted October 19, 2004 Author Report Share Posted October 19, 2004 :) paldies, ar juusu paliidziibu sanaak Link to comment Share on other sites More sharing options...
bubu Posted October 19, 2004 Report Share Posted October 19, 2004 jautājums bija man? Nē, ne tev. Kad es savu postu rakstīju, tava vēl nemaz nebija :) Link to comment Share on other sites More sharing options...
Recommended Posts