我正在尝试从日期中提取月份,看起来像这样“2008-08-17 00:00:00”
这是一个例子,我尝试在这里组合两个表,即 db_match 和 Country,如您所见,但我需要从整个日期中提取月份,所以我可以在这里尝试什么?
我尝试过,
update db_match set date=str_to_date(date,"%Y/%m/%d %h:%i:%s");
这是联接查询:
select db_match.date,country.name,country.id
from db_match(
select EXTRACT (MONTH FROM date) as Themonth
)sub
inner join country
on country.id=db_match.country_id
group by Themonth
order by id;
This is an example,Im trying combine two tables here which are db_match and country as you can see but I need to extract just month from the whole date so what could I try here ?
I tried,
update db_match set date=str_to_date(date,"%Y/%m/%d %h:%i:%s");
here's the join query:
select db_match.date,country.name,country.id
from db_match(
select EXTRACT (MONTH FROM date) as Themonth
)sub
inner join country
on country.id=db_match.country_id
group by Themonth
order by id;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
MONTH()
注意:您已经标记了 mySQL,这在 mySQL 中有效吗?我现在没有qsqldatabase。
返回 8
您的查询将类似于以下内容。没有您的表格描述和示例数据,我无法对其进行测试。
Use
MONTH()
NB You have tagged mySQL and this works in mySQL? I don't now qsqldatabase.
returns 8
Your query becomes something like the following. I can't test it without your table descriptions and sample data.