当前位置:网站首页>Oracle database merge row records, wmsys WM_ Use of the concat function and group in MySQL_ Use and comparison of concat (ID).
Oracle database merge row records, wmsys WM_ Use of the concat function and group in MySQL_ Use and comparison of concat (ID).
2022-06-11 16:42:00 【Peach】
Oracle: wmsys.wm_concat()
Put result set in one column , By comma ‘,’ separate
Columns such as :
oracle10g The above version provides the function of combining row to column into a string wmsys.wm_concat
For example, there is a users The table is as follows :
id yhm xm
1 001 Xiaotang
2 002 petty thief
3 003 Xiao Zhang
selectwmsys.wm_concat(yhm) user name , wmsys.wm_concat(xm) full name from users
The execution result is :
user name full name
001,002,003 Xiaotang , petty thief , Xiao Zhang
wmsys.wm_concat() The parameters in can also make multiple , Use ”||” Splicing , The following example :
select deptno,wmsys.wm_concat(ename || '-' || job) name from emp group by deptno;
The results are shown in the following table :
deptno | ename |
10 | CLARK-MANAGER,MILLER-CLERK,KING-PRESIDENT
|
20 | SMITH-CLERK,FORD-ANALYST,ADAMS-CLERK,SCOTT-ANALYST,JONES-MANAGER |
30 | ALLEN-SALESMAN,JAMES-CLERK,TURNER-SALESMAN,BLAKE-MANAGER,MARTIN-SALESMAN,WARD-SALESMAN |
( You can also use group by Group display and merge )
MySQL:GROUP_CONCAT()
Put the result set together , Separated by commas by default , You can use [] Set up
With id grouping , hold name The value of the field is printed on one line , Comma separated ( Default )
1. select id,group_concat(name) from aa group by id;
With id grouping , hold name The value of the field is printed on one line , Semicolons separate
1. select id,group_concat(name separator ';') from aa group
2. by id;
With id grouping , Remove redundant name The value of the field is printed on one line ,
Comma separated
Sql Code
1. select id,group_concat(distinct name) from aa group by id;
边栏推荐
- leetcode684. 冗余连接(中等)
- “is-a”,“has-a”,“like-a”
- Research Report on operation mode and investment opportunities of China's aluminum industry 2022-2028
- golang中的异常处理和异常使用
- leetcode-141. Circular linked list
- Analysis report on sales status and supply and demand prospects of phosphoric acid fuel cell industry in the world and China 2022-2028 Edition
- leetcode-141.环形链表
- Elasitcsearch基础学习笔记(1)
- 做跨境电商卖什么产品好?热销类目有哪些?
- If you want to learn ArrayList well, it is enough to read this article
猜你喜欢

tornado环境搭建及基本框架搭建——熟悉的hello world

一套ThinkPHP微信小程序商城源码带后台管理

【opencvsharp】opencvsharp_ samples. Core sample code Notes

Memory image of various data types in C language

【clickhouse专栏】新建库、用户及角色

2022高压电工特种作业证考试题库及在线模拟考试

leetcode417. Pacific Atlantic current problems (medium)

瑞吉外卖项目(三)员工管理业务开发

2022年R1快開門式壓力容器操作考試題庫及模擬考試

Detailed explanation of the functions of list and dict data types
随机推荐
jsp页面初始加载方式
Simulated 100 questions and simulated examination for main principals of hazardous chemical business units in 2022
2022 high voltage electrician special operation certificate examination question bank and online simulation examination
回归预测 | MATLAB实现RBF径向基神经网络多输入单输出
Rdkit tutorial
^31 prototype interview questions
Analysis report on future development trend and investment suggestions of global and Chinese soybean protein industry 2022-2028
Analysis report on sales status and supply and demand prospects of phosphoric acid fuel cell industry in the world and China 2022-2028 Edition
Katalon Studio Enterprise
leetcode417. 太平洋大西洋水流问题(中等)
leetcode684. Redundant connection (medium)
【剑指Offer】21.调整数组顺序使奇数位于偶数前面
减肥期间可以吃肉吗?会胖吗?
20 full knowledge maps of HD data analysis have been completed. It is strongly recommended to collect them!
ShellBrowser .NET Crack
List和Set存取元素的差异
What is a generic? Why use generics? How do I use generics? What about packaging?
VLAN partition and routing between VLANs
虚拟局域网划分与虚拟局域网间路由(VLAN)
leetcode463. Perimeter of the island (simple)