当前位置:网站首页>MySQL winter vacation self-study 2022 12 (1)
MySQL winter vacation self-study 2022 12 (1)
2022-07-04 00:19:00 【Crane paper thousand】
function
group_concat
Data preparation
create database mydb4;
use mydb4;
create table emp
(
emp_id int primary key auto_increment comment ' Number ',
emp_name char(20) not null default '' comment ' full name ',
salary decimal(10,2) not null default 0 comment ' Wages ',
department char(20) not null default '' comment ' department '
);
insert into emp(emp_name,salary,department)
values(' Zhang Jingjing ',5000,' Finance Department '),
(' Wang Feifei ',5800,' Finance Department '),
(' Zhao Gang ',6200,' Finance Department '),
(' Liu Xiaobei ',5700,' The personnel department '),
(' Wang Dapeng ',6700,' The personnel department '),
(' Zhang Xiaofei ',5200,' The personnel department '),
(' Liu yunyun ',7500,' The sales department '),
(' Liu Yunpeng ',7200,' The sales department '),
(' Liu Yunpeng ',7800,' The sales department ');
part1
-- Put the names of all employees in one line
select group_concat(emp_name) from emp;
The operation results are as follows
part2
-- Specify the separator
select group_concat(emp_name separator ';') from emp;
The operation results are as follows
part 3
-- Splicing after grouping
select department,group_concat(emp_name separator ';') from emp group by department;
part 4 Sort by salary
-- Splicing after grouping , And sort
select department,group_concat(emp_name order by salary desc separator ';') from emp group by department;
边栏推荐
- What is the difference between NFT, SFT and dnft? How to build NFT platform applications?
- It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
- 2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination
- 炒股開戶傭金優惠怎麼才能獲得,網上開戶安全嗎
- BBS forum recommendation
- P3371 [template] single source shortest path (weakened version)
- [leetcode] interview question 17.08 Circus tower
- How to solve the "safe startup function prevents the operating system from starting" prompt when installing windows10 on parallel desktop?
- Zipper table in data warehouse (compressed storage)
- Analysis: misunderstanding of choosing WMS warehouse management system
猜你喜欢
URL (data:image/png; Base64, ivborw0k... Use case
Briefly understand the operation mode of developing NFT platform
Idea integrates Microsoft TFs plug-in
2022 system integration project management engineer examination knowledge points: software development model
Qtcharts notes (V) scatter diagram qscatterseries
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query
SPI based on firmware library
Docking Alipay process [pay in person, QR code Payment]
Pytorch learning notes 5: model creation
随机推荐
Gossip about redis source code 80
The interviewer's biggest lie to deceive you, bypassing three years of less struggle
[C language] break and continue in switch statement
Global and Chinese markets for instant saliva testing devices 2022-2028: Research Report on technology, participants, trends, market size and share
How to trade spot gold safely?
Global and Chinese market of underwater bags 2022-2028: Research Report on technology, participants, trends, market size and share
Gossip about redis source code 79
P1339 [USACO09OCT]Heat Wave G
What is the difference between NFT, SFT and dnft? How to build NFT platform applications?
Gossip about redis source code 83
[about text classification trick] things you don't know
Distributed transaction -- middleware of TCC -- selection / comparison
Introducing Software Testing
2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination
D26: the nearest number (translation + solution)
D24:divisor and multiple (divisor and multiple, translation + solution)
Research Report on the scale prediction of China's municipal engineering industry and the prospect of the 14th five year plan 2022-2028
Zipper table in data warehouse (compressed storage)
Global and Chinese market of breast cancer imaging 2022-2028: Research Report on technology, participants, trends, market size and share
Idea set class header comments