mach1ne^ Posted December 14, 2009 Report Share Posted December 14, 2009 (edited) Vajadzētu izvilkt datus no tabulas, kurā viens no laukiem ir datums. Datuma tabulas laukā ieraksti ir yyyy-mm-dd. select * from table where datums='yyyy-15-12' Tātad, lai netiek ņemts vērā gada(yyyy), jo yyyy var būt jebkāds, bet gan tik mēnesi (mm) un dienu (dd). Ja nesaprotami uzrakstīju, tad vajadzētu izvilkt precīzāk datus priekš dz/d, neatkarīgi, kurā gadā dzimis. Edited December 14, 2009 by mach1ne^ Quote Link to comment Share on other sites More sharing options...
ohmygod Posted December 15, 2009 Report Share Posted December 15, 2009 nu, ja pašas kolonnas tips ir kāds no laika tipiem, tad ir vesela čupa ar visādām mysql funkcijām kā dabūt, ko vēlies. lasi šito: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Quote Link to comment Share on other sites More sharing options...
briedis Posted December 15, 2009 Report Share Posted December 15, 2009 (edited) Ja tas ir varchar, tad var izmantot LIKE operatoru. SELECT * FROM kautkas WHERE datums LIKE '____-15-12' "_" (apakšvītra) apzīmē, ka tur var būt jebkāds simbols. "%" apzīmē, ka tur var būt jebkāds un jebcik simbolu(var arī nebūt neviens) - ..LIKE "%-15-12" Edited December 15, 2009 by briedis Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted December 16, 2009 Report Share Posted December 16, 2009 (edited) SELECT * FROM tbulis WHERE MONTH(datums)='12' AND DAYOFMONTH(datums)='16' Edited December 16, 2009 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.