当前位置:网站首页>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 !
边栏推荐
- 2022 Q2 - résumé des compétences pour améliorer les compétences
- With the innovation and upgrading of development tools, Kunpeng promotes the "bamboo forest" growth of the computing industry
- Deep learning: a solution to over fitting in deep neural networks
- Word search applet design report based on cloud development +ppt+ project source code + demonstration video
- 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
- Three core problems of concurrent programming
- This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
- JMeter (I) - download, installation and plug-in management
- Matlab uses resample to complete resampling
- Number of palindromes in C language (leetcode)
猜你喜欢

如何远程、在线调试app?

SQLite 3 of embedded database

Redis环境搭建和使用的方法

The role of artificial intelligence in network security

Feature extraction and detection 16 brisk feature detection and matching

Golang lock
![[技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术](/img/2d/299fa5c76416f74bd1a693c433dd09.png)
[技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术

MySQL中一条SQL是怎么执行的
![[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing](/img/ba/dcb276768b1a9cc84099f093677d29.png)
[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing

PR second training
随机推荐
5g/4g pole gateway_ Smart pole gateway
Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?
并发编程的三大核心问题
Electronic Society C language level 1 32, calculate the power of 2
matlab 实现语音信号重采样和归一化,并播放比对效果
The technology boss is ready, and the topic of position C is up to you
np.where 和 torch.where 用法
Electronic Association C language level 1 33, odd even number judgment
The role of artificial intelligence in network security
城市选择器组件实现原理
Redis环境搭建和使用的方法
k线图形态这样记(口诀篇)
PR second training
Laravel artisan common commands
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
Is the knowledge of University useless and outdated?
如何远程、在线调试app?
Construction and maintenance of business websites [15]
leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
剑指 Offer II 031. 最近最少使用缓存