在mysql中生成月份列表 [英] Generate list of months in mysql

查看:107
本文介绍了在mysql中生成月份列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要加入一个现有表格,其中包含给定时期内的月份列表的日期条目.为此,我需要临时生成此期间内的月份列表.

I need to join an existing table with date entries with a list of months in a given period. For this I would need to temporary generate a list of months within this period.

mysql 中是否有执行此操作的命令?临时表,存储过程?

Is there a command in mysql for doing this? Temporary Table, stored procedure?

谢谢,马丁

推荐答案

我不确定我是否完全理解您的问题,但您可能正在寻找这样的问题:

I'm not sure I fully understand your question, but something like this might be what your looking for:

选择*从 existing_table et在 mt.month = month(et.date)

select * from existing_table et join month_table mt on mt.month = month(et.date)

这篇关于在mysql中生成月份列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆