Home > Database > Mysql Tutorial > body text

Detailed explanation of how to use the concat function of mysql function splicing query

小云云
Release: 2017-12-25 13:22:54
Original
1997 people have browsed it

This article mainly brings you an article on how to use the concat function of mysql function splicing query. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.

is as follows:


##

//查询表managefee_managefee的年year 和 month ,用concat函数拼成year-month。例如将2017和1 拼成2017-01。.
select CONCAT(a.year,&#39;-&#39;,if(a.month<=9,CONCAT(&#39;0&#39;,a.month),a.month))as date,a.* from managefee_managefee as a;

//查询managefee_managefee中时间段为2017-01到2017-07的数据
select * from
(
select CONCAT(a.year,&#39;-&#39;,if(a.month<=9,CONCAT(&#39;0&#39;,a.month),a.month))as date,a.* from managefee_managefee as a
) b
where b.date between &#39;2017-01&#39; and &#39;2017-07&#39;;
Copy after login

Related recommendations:


JavaScript method concat() to connect two or more arrays

Detailed examples of using the group_concat() function in MySQL

In-depth understanding of the concat method in javascript

The above is the detailed content of Detailed explanation of how to use the concat function of mysql function splicing query. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!