当前位置:网站首页>What is the MySQL column to row function
What is the MySQL column to row function
2022-07-02 01:55:00 【Yisu cloud】
mysql What does the column to row function mean
This article mainly explains “mysql What does the column to row function mean ”, The explanation in the text is simple and clear , Easy to learn and understand , Next, please follow Xiaobian's ideas and go deeper slowly , Study and learn together “mysql What does the column to row function mean ” Well !
stay mysql in , The column to row function is “group_concat()” function ; This function is used to merge non empty column values according to grouping conditions and finally return , If there is a null value, the returned result is null , The grammar is “select group_concat(name separator ';') Name from Table name ;”.
The operating environment of this tutorial :windows10 System 、mysql8.0.22 edition 、Dell G3 The computer .
mysql What is the column to row function
GROUP_CONCAT(expr) This function combines the non empty column values according to the grouping conditions and finally returns . If there is a null value , Then return to empty
stay MySQL in , How to turn a column into a row ? For example, a commodity will belong to multiple categories ( For example, Huawei mobile phones can be classified as mobile phones , It can also be digital classification ), How to show all categories of this commodity in one piece of data .
The idea is simple , adopt MySQL function group_concat Can solve .
Create test table :
create table test.test_mysql_liezhuanhang (id bigint auto_increment comment ' Primary key ',name varchar(100),age int(5),primary key (id))engine=innodb default charset=utf8mb4 comment=' The test table '
Import test data :
insert into test.test_mysql_liezhuanhang (name, age) values (' Li Wei ', 18), (' Li Wei ', 19), (' Li Wei ', 18), (' Li Bai ', 20), (' Li Bai ', 20), (' Li Bai ', 19); Show all names , Divide by semicolon , Default to , Division
select group_concat(name separator ';') concat from test.test_mysql_liezhuanhang ;

Show all names , And duplicate the same name
select group_concat(distinct name) concat from test.test_mysql_liezhuanhang ;

Show all ages , De duplication and sort in ascending order of age
select group_concat(distinct age order by age) concat from test.test_mysql_liezhuanhang ;

Thank you for reading , That's all “mysql What does the column to row function mean ” Content. , After learning this article , I'm sure you're right mysql We have a deeper understanding of what the column to row function refers to , The specific use needs to be verified by practice . This is billion speed cloud , Xiaobian will push you articles with more relevant knowledge points , Welcome to your attention !
边栏推荐
- Matlab uses audioread and sound to read and play WAV files
- Implementation of Weibo system based on SSM
- 【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享
- Android high frequency network interview topic must know and be able to compare Android development environment
- Three core problems of concurrent programming
- Construction and maintenance of business websites [15]
- Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories
- How to use a product to promote "brand thrill"?
- leetcode2309. 兼具大小写的最好英文字母(简单,周赛)
- This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
猜你喜欢

Three core problems of concurrent programming

321. Chessboard segmentation (2D interval DP)

1069. Division of convex polygons (thinking, interval DP)

城市选择器组件实现原理

Have you stepped on the nine common pits in the e-commerce system?

Should enterprises choose server free computing?

机器学习基本概念

Software No.1

MPLS experiment operation

From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
随机推荐
D discard the virtual recovery method
Openssl3.0 learning XXI provider encoder
1222. Password dropping (interval DP, bracket matching)
The role of artificial intelligence in network security
[Floyd] post disaster reconstruction
医药管理系统(大一下C语言课设)
SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
Golang lock
Is the knowledge of University useless and outdated?
There are spaces in the for loop variable in the shell -- IFS variable
三分钟学会基础k线图知识
Learn basic K-line diagram knowledge in three minutes
Android high frequency network interview topic must know and be able to compare Android development environment
Penser au jeu 15: penser au service complet et au sous - service
Opengauss database backup and recovery guide
1217 supermarket coin processor
321. Chessboard segmentation (2D interval DP)
Bat Android Engineer interview process analysis + restore the most authentic and complete first-line company interview questions
Five skills of adding audio codec to embedded system
Architecture evolution from MVC to DDD