当前位置:网站首页>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 !
边栏推荐
- 遊戲思考15:全區全服和分區分服的思考
- 【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享
- Introduction to ffmpeg Lib
- leetcode2310. The one digit number is the sum of integers of K (medium, weekly)
- Modeling essays series 124 a simple coding method
- 2022 Q2 - 提升技能的技巧总结
- Matlab uses audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound
- The role of artificial intelligence in network security
- What is AQS and its principle
- 479. Additive binary tree (interval DP on the tree)
猜你喜欢

医药管理系统(大一下C语言课设)

Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage

成功实现边缘编码需要了解的六大经验教训

MySQL中一条SQL是怎么执行的

5g/4g pole gateway_ Smart pole gateway

剑指 Offer 62. 圆圈中最后剩下的数字

Three core problems of concurrent programming

MySQL主从延迟问题怎么解决

PR second training

Implementation principle of city selector component
随机推荐
Selection of field types for creating tables in MySQL database
MySQL中一条SQL是怎么执行的
分卷压缩,解压
new和malloc的区别
What style of Bluetooth headset is easy to use? High quality Bluetooth headset ranking
Makefile simple induction
自动浏览拼多多商品
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
Ubuntu20.04 PostgreSQL 14 installation configuration record
开发工具创新升级,鲲鹏推进计算产业“竹林”式生长
2022 Q2 - 提昇技能的技巧總結
开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
Bat Android Engineer interview process analysis + restore the most authentic and complete first-line company interview questions
This is the form of the K-line diagram (pithy formula)
跨域?同源?一次搞懂什么是跨域
人工智能在网络安全中的作用
Architecture evolution from MVC to DDD
如何远程、在线调试app?
Redis环境搭建和使用的方法
SQLite 3 of embedded database