MySQL Common functions

Source: Internet
Author: User

First, CONCAT and Group_concat

1. The CONCAT () function is used to concatenate multiple strings into a single string.

Examples of Use:
SELECT CONCAT (ID, ', ', name) as con from Info LIMIT 1; return result is
+----------+
|con

|
+----------+
| 1,BIOCYC |
+----------+

2. Group_concat often used with GROUP by

The Group_concat function returns a string result that is combined by a value in the grouping

SEPARATOR delimiter

SELECT
Tbl_user.sex,
Group_concat (tbl_user.user_name SEPARATOR ' | | ') As user_name
From
Tbl_user
GROUP by
Tbl_user.sex

Sex user_name
Ladies International Hotel to see | | Normalize the Law of the Republic | | A good sad years and the country | | Send
Men's Republic | | Retro style Wide Sense | | Citi No Fun | | Kerala | | Go home several | | It's very high and high. | Hu Geng | | Share Repurchase | | Personal Unit

Second, date_format

The Date_format () function is used to display date/time data in different formats.

Date_format (Date,format)
The date parameter is a valid day. format Specifies the date/time in which the output is formatted.

Select Date_format (Time, '%y-%m-%d%h:00 ') Datespan,max (bandwith) MaxBandWidth from
TableName where time>= ' 2016-01-01 00:00:00 ' and time< ' 2016-02-24 00:00:00 ' GROUP by Datespan

The output of the Datespan column is timeformat for the date_format specified by the

This article is from the "program Ape's Cultivation" blog, please be sure to keep this source http://zhoum1118.blog.51cto.com/10054110/1744618

MySQL Common functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.