当前位置:网站首页>Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
2022-07-03 14:13:00 【Big data Wang】
1 :concat Function can connect one or more strings , Such as
select concat('10');//10
select concat('11','22','33');//1122332:concat Function when connecting strings , As long as one of them is NULL, Then it will return to NULL
select concat('11','22',null);//null3:concat_ws() function ,
Express concat with separator, That is, string connection with separator
select concat_ws(',','11','22','33');//11,22,33
select concat_ws('|','11','22','33');//11|22|33
select concat_ws('*','11','22',NULL);//11*22and concat The difference is , concat_ws When the function is executing , Not because NULL Value NULL
4:
group_concat()
Available row to column
The complete grammar is as follows :
group_concat([DISTINCT] Fields to connect [Order BY ASC/DESC Sort field ] [Separator ‘ Separator ’])
Example :
create table aa(
id int,
name VARCHAR(255)
);
insert into aa values(1,10);
insert into aa values(1,10);
insert into aa values(1,20);
insert into aa values(1,30);
insert into aa values(3,30);
insert into aa values(5,60);
insert into aa values(5,90);
insert into aa values(6,990);
1 With id grouping , hold name The value of the field is printed on one line , Comma separated ( Default )
select id,group_concat(name) from aa group by id;
2 With id grouping , hold name The value of the field is printed on one line , Semicolons separate
select id,group_concat(name separator ';') from aa group by id;
3 With id grouping , Remove redundant name The value of the field is printed on one line , Comma separated
select id,group_concat(distinct name separator ';') from aa group by id;
4 With id grouping , hold name The value of the field is printed on one line ,* No separation , With name Reverse order
select id,group_concat(name order by name desc separator "*") from aa group by id;
eg:
select * from aa;

select id,group_concat(name) from aa group by id;

select id,group_concat(name separator ';') from aa group by id;
select id,group_concat(distinct name separator ';') from aa group by id;

select id,group_concat(name order by name desc separator "*") from aa group by id;

边栏推荐
- JS Part 2
- 怎样删除对象的某个属性或⽅法
- QT learning 24 layout manager (III)
- [clean up the extraordinary image of Disk C]
- 28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
- Redis:字符串類型數據的操作命令
- Failure of vector insertion element iterator in STL
- 全局事件总线
- UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
- js . Find the first palindrome string in the array
猜你喜欢

7-11 calculation of residential water charges by sections

Redis:字符串类型数据的操作命令

Interface for querying IP home
[email "/>Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email

Dlopen() implements dynamic loading of third-party libraries

Qt学习21 Qt 中的标准对话框(下)

Print. JS -- web page file printing

JS input number and standard digit number are compared. The problem of adding 0 to 0

Qt学习23 布局管理器(二)
[email protected])|制备路线"/>叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
随机推荐
QT learning 21 standard dialog box in QT (Part 2)
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
fpga阻塞赋值和非阻塞赋值
QT learning 25 layout manager (4)
Exercise 6-1 classify and count the number of characters
C library function - qsort()
QT learning 17 dialog box and its types
Duet date picker (time plug-in that can manually enter the date)
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(
Fabric. JS document
Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
How to use lxml to judge whether the website announcement is updated
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
Multi person collaborative data annotation based on Baidu brain easydata from scratch
常见问题之PHP——ldap_add(): Add: Undefined attribute type in
FPGA test method takes mentor tool as an example
Use vscode to view hex or UTF-8 codes
Similarities and differences of sessionstorage, localstorage and cookies
Exercise 10-1 calculate the sum of 1 to n using recursive functions
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;