Mikijs Posted July 25, 2008 Report Share Posted July 25, 2008 Sveiki, man ir aptuveni sada sql tabula id | datums | laiks | nosaukums -------------------------------------------- 1 | 2008-13-07 | 11:10 | Sports 2 | 2008-15-08 | 18:05 | Izklaide 3 | 2008-28-11 | 23:11 | Jaunumi 4 | 2009-08-03 | 23:11 | Jaunumi 5 | 2009-02-12 | 23:11 | Jaunumi Ka lai es sorteju pec datuma ? (YY-mm-dd) ? izmantojo "select * from tabula order by date desc" ... nesorte ka vaig.. kolona "date" arii ir type:date Link to comment Share on other sites More sharing options...
bubu Posted July 25, 2008 Report Share Posted July 25, 2008 Tāpēc, ka datumu vajag glabāt yyyy-mm-dd formā, tad sortēs pareizi. Var jau manuāli pārveidot datumu no yyyy-dd-mm uz yyyy-mm-dd ar MySQL datumu funkcijām tajā order by XXX daļā. Bet tad būs liela bremze. Nez vispār kā tu DATE tipa kolonna esi dabūjis datus yyyy-dd-mm formā? DATE A date. The supported range is '1000-01-01' to '9999-12-31'. MySQL displays DATE values in 'YYYY-MM-DD' format, but allows assignment of values to DATE columns using either strings or numbers. (iz http://dev.mysql.com/doc/refman/5.0/en/dat...-overview.html) Link to comment Share on other sites More sharing options...
andrisp Posted July 25, 2008 Report Share Posted July 25, 2008 (edited) Mikijs, kā tad viņš sasortē ? Mjā, Mikij, ko tu atkal tu mahinē.. :) Edited July 25, 2008 by andrisp Link to comment Share on other sites More sharing options...
Mikijs Posted July 25, 2008 Author Report Share Posted July 25, 2008 andrisp :D baig sudigi sasorte select * from table where user='$iMEMBER[id]' order by date Sasorteja sita Datums | Laiks 2008-07-27 08:31 2008-07-23 20:30 2008-07-23 22:30 2008-07-23 22:30 2008-07-24 20:40 2008-07-24 20:40 2008-07-24 20:40 2008-07-27 12:31 2008-07-29 11:30 2008-08-27 20:03 2008-09-23 18:29 2008-10-26 23:30 gandriz pareizi tikai ka es skatos tad 1 laucinjs ir augstaks datums neka 2 :) andrisp :D vienmer kko taisu Link to comment Share on other sites More sharing options...
Aleksejs Posted July 25, 2008 Report Share Posted July 25, 2008 Mikij, vai Tev sagādā baudu parādīt tabulu ar vieniem lauku nosaukumiem un tad SQLu ar citiem lauku nosaukumiem? Vajag ORDER BY datums, laiks Link to comment Share on other sites More sharing options...
andrisp Posted July 25, 2008 Report Share Posted July 25, 2008 Aleksej, 99%, ka viņam tas lauks nemaz nav ar date tipu. Link to comment Share on other sites More sharing options...
Mikijs Posted July 25, 2008 Author Report Share Posted July 25, 2008 ja palasisi ieprieks es jau pateicu ka date = type:date un kkas nesortejas Link to comment Share on other sites More sharing options...
andrisp Posted July 25, 2008 Report Share Posted July 25, 2008 Parādi tabulas CREATE sql. Link to comment Share on other sites More sharing options...
Mikijs Posted July 25, 2008 Author Report Share Posted July 25, 2008 CREATE TABLE IF NOT EXISTS `notify` ( `id` int(255) unsigned NOT NULL auto_increment, `user` int(255) NOT NULL, `time` varchar(10) NOT NULL, `date` varchar(10) NOT NULL, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; Link to comment Share on other sites More sharing options...
andrisp Posted July 25, 2008 Report Share Posted July 25, 2008 (edited) Apbrīnojami!! Mikij, tu tiešām neredzi ? `date` varchar(10) NOT NULL, Edited July 25, 2008 by andrisp Link to comment Share on other sites More sharing options...
Mikijs Posted July 25, 2008 Author Report Share Posted July 25, 2008 wtf? .. es biju spiedis tipa edit column un tur radijas date.. :/ mo6 ne to tabulu uzspiedu :P peidod Link to comment Share on other sites More sharing options...
andrisp Posted July 25, 2008 Report Share Posted July 25, 2008 Mja. Link to comment Share on other sites More sharing options...
Recommended Posts