MySql取最近七天的日期字符串

SELECT
	DATE_FORMAT( date, '%Y-%m-%d' ) date
FROM
	(
	SELECT
		@s := @s + 1 AS `index`,
		DATE(
		DATE_SUB( CURRENT_DATE, INTERVAL @s DAY )) AS `date` 
	FROM
		mysql.help_topic,(
		SELECT
			@s := - 1 
		) temp 
	WHERE
		@s < 6 
	) a 
ORDER BY
	`date` DESC

你可能感兴趣的:(mysql,数据库,最近日期)