我在表中有一个日期型字段是用来保存登记日期的,现在要根据该字段来查询某月的所有记录,这样的SQL语句要如何写?

解决方案 »

  1.   

    select * from tablename
    where mydata<='2003-01-31' and mydata>='2003-01-01';
      

  2.   

    njtu(mage) :你理解错了我的意思。这样写是查询某个时间段的记录了。
      

  3.   

    select * from tablename
    where month(登记日期字段名称) = 统计月份 and year(登记日期字段名称) = 统计年份
      

  4.   

    select * from tablename where  日期 between strtodate('2003-01-01') and 
                                                strtodate('2003-01-31')