mysql中怎么查询某年某月的数据

mysql中如何查询某年某月的数据

如题。。

假设数据表为

|   note     |   CREATE   TABLE   `note`   (

    `id`   int(11)   NOT   NULL   auto_increment,

    `pid`   int(11)   default   NULL,

    `title`   varchar(100)   default   NULL,

    `content`   varchar(1000)   default   NULL,

    `time`   date   default   NULL,

    `level`   char(1)   default   NULL,

    PRIMARY   KEY     (`id`)

)   ENGINE=InnoDB   DEFAULT   CHARSET=latin1   |

如何根据time字段查出2007年5月的数据



select * from note where date_format(time, ‘%Y%m ‘)= ‘200705 ‘




select * from note where strcmp(date_format(time, ‘%Y-%m ‘), ‘2007-05 ‘) = 0;

mysql中怎么查询某年某月的数据

相关文章:

你感兴趣的文章:

标签云: