Home > database >  How do you use the mysql concat function
How do you use the mysql concat function

Time:09-27

Select concat (' substring_index (name, '. ', 1) as name1 ', "-", "substring_index (name, ':', 1) as name2 ') as name3 from tb1
How do you change this statement?
Between before and after values in the field name, such as 40019. The test; Height: 5012 m is: 400019-5012 - m

CodePudding user response:

 
The SET @ TMP:='40019. The test; Height: 5012 meters';
SELECT CONCAT (SUBSTR (@ TMP, 1, INSTR (@ TMP, '. ') - 1), '-', SUBSTR (@ TMP, INSTR (@ TMP, ':') + 1))

CodePudding user response:

Take the field in the table name value in the treatment

CodePudding user response:

Select concat (substring_index (name, '. ', 1), "-", substring_index (name, ':', 1)) as name1 from tb1

CodePudding user response:

Positive solution
 
The SET @ TMP:='40019. The test; Height: 5012 meters';
SELECT CONCAT (SUBSTR (@ TMP, 1, INSTR (@ TMP, '. ') - 1), '-', SUBSTR (@ TMP, INSTR (@ TMP, ':') + 1))
  • Related