Mysql查询当前日期前六个月

SELECT
		DATE_FORMAT( CURDATE(), '%Y-%m' ) AS MONTH UNION
	SELECT
		DATE_FORMAT(( CURDATE() - INTERVAL 1 MONTH ), '%Y-%m' ) AS MONTH UNION
	SELECT
		DATE_FORMAT(( CURDATE() - INTERVAL 2 MONTH ), '%Y-%m' ) AS MONTH UNION
	SELECT
		DATE_FORMAT(( CURDATE() - INTERVAL 3 MONTH ), '%Y-%m' ) AS MONTH UNION
	SELECT
		DATE_FORMAT(( CURDATE() - INTERVAL 4 MONTH ), '%Y-%m' ) AS MONTH UNION
	SELECT
		DATE_FORMAT(( CURDATE() - INTERVAL 5 MONTH ), '%Y-%m' ) AS MONTH

你可能感兴趣的:(mysql)