Home > database >  Replace mysql character between before and after the interception
Replace mysql character between before and after the interception

Time:10-15

Is this:
Some data in the table/uploads/allimg/1811 XXXXX. JPG I think I want to put this batch to uploads/aaa/XXXXX. JPG
Note: this is not a fixed 1181
Excuse me, how to intercept, you can write a complete code? Thank you,

CodePudding user response:

Personal ideas can be directly capture/XXXXX. JPG, then add uploads/aaa

CodePudding user response:

/*
Some data in the table/uploads/allimg/1811 XXXXX. JPG
I think I want to put this batch to uploads/aaa/XXXXX. JPG
*/
- the method 1
Select concat (' uploads/aaa/' REVERSE (SUBSTRING (REVERSE (' 1811/uploads/allimg/XXXXX. JPG ') FROM 1 FOR the LOCATE ('/', REVERSE (' 1811/uploads/allimg/XXXXX. JPG ')) - 1)));
- the method 2
Select insert (' 1811/uploads/allimg/XXXXX. JPG ', LOCATE ('/', '1811/uploads/allimg/XXXXX. JPG') + 1, LOCATE ('/', '1811/uploads/allimg/XXXXX. JPG', LOCATE ('/', '1811/uploads/allimg/XXXXX. JPG', LOCATE ('/', '1811/uploads/allimg/XXXXX. JPG') + 1) + 1) - the LOCATE ('/', '1811/uploads/allimg/XXXXX. JPG') - 1, "aaa");


  • Related