当前位置:网站首页>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 audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound
- JMeter (I) - download, installation and plug-in management
- MySQL如何解决delete大量数据后空间不释放的问题
- TSINGSEE青犀平台如何实现同一节点同时播放多个视频?
- 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?
- Three core problems of concurrent programming
- Is the knowledge of University useless and outdated?
- Exception handling of class C in yyds dry goods inventory
猜你喜欢
Data analysis on the disaster of Titanic
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
k线图形态这样记(口诀篇)
三分钟学会基础k线图知识
Memorabilia of domestic database in June 2022
New news, Wuhan Yangluo international port, filled with black technology, refreshes your understanding of the port
Volume compression, decompression
企业应该选择无服务器计算吗?
开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
成功实现边缘编码需要了解的六大经验教训
随机推荐
TSINGSEE青犀平台如何实现同一节点同时播放多个视频?
遷移雲計算工作負載的四個基本策略
JMeter (I) - download, installation and plug-in management
Construction and maintenance of business websites [13]
479. Additive binary tree (interval DP on the tree)
Raspberry pie 4B learning notes - IO communication (1-wire)
[C #] use regular verification content
Android high frequency network interview topic must know and be able to compare Android development environment
What style of Bluetooth headset is easy to use? High quality Bluetooth headset ranking
[question] - why is optical flow not good for static scenes
Have you stepped on the nine common pits in the e-commerce system?
三分钟学会基础k线图知识
Matlab uses audioread and sound to read and play WAV files
MySQL如何解决delete大量数据后空间不释放的问题
Construction and maintenance of business websites [11]
Electronic Society C language level 1 32, calculate the power of 2
Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
KS006基于SSM实现学生成绩管理系统
Medical management system (C language course for freshmen)
matlab 使用 audioread 、 sound 读取和播放 wav 文件