我想在两个日期之间创建一个月份名称列表。通过mysql查询的最佳方法是什么。
Select start_date, end_date from table where id=123
以上查询结果 - 开始日期:' 2016-01-15'结束日期:' 2017-04-28'
最终结果应为:
Jan-16
Feb-16
Mar-16
......
......
......
Feb-17
Mar-17
Apr-17
感谢您的帮助!
答案 0 :(得分:0)
没有时间需要现在只需搜索Date_Format到此select CONCAT_WS('-',monthname(date(thisday)),substr(thisday from 9 FOR 2)) from
(SELECT ADDDATE('2017-01-01', INTERVAL @i:=@i+1 DAY) AS thisday
FROM (
SELECT a.a
FROM (SELECT 0 AS a UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) AS a
CROSS JOIN (SELECT 0 AS a UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) AS b
CROSS JOIN (SELECT 0 AS a UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) AS c
) a
JOIN (SELECT @i := -1) r1
WHERE
@i < DATEDIFF('2017-01-31', '2017-01-01')) as a
January-18
January-19
January-20
January-21
January-22
January-23
January-24
January-25
January-26
January-27
January-28
January-29
一些结果:
root
out
test1
test1.exe
test2
test2.exe
test3
test3.exe
bin
run_test.exe