mysql attribute splicing function

1. Concat multiple fields splicing.

Such as: select concat('1','2','3') from test; result: 123

select concat(content_title,"|",content_price) from contents ;  

2 , concat_ws(separator,str1,str2,…) multiple fields are spliced, the first parameter is the separator of other parameters

Such as: select concat_ws(':','1','2','3') from test; result: 1:2:3

select concat_ws("|",content_title,content_price,speaker) from contents ;  

3 , group_concat multi-line result splicing

select group_concat(column_name) 
from information_schema.columns 
where table_schema='exchange' and table_name='bf_dd';

Other functions

substring intercept string:

substring(str, pos) Description: substring (the field to be intercepted, starting from the first few digits)

substring(str, pos, length) substring (the field to be intercepted, starting from the first few digits, and the length of the interception)

select substring(content,5) as abstract from my_content_t 
select substring(content,5,200) as abstract from my_content_t 

Guess you like

Origin blog.csdn.net/fangye1/article/details/110952754