Use the trim function in MYSQL syntax to delete bitsCN.com characters on both sides.
In actual development, you always encounter this situation.
Or in this case
If you are still using select fields from table where like '/%', it is definitely a thankless practice, taking a closer look at the built-in functions of MYSQL is definitely the first priority. I first thought that the trim in the PHP function may also be used in mysql. The answer is yes. You can find it in the MYSQL Manual. of course, you can refer to Baidu. what I am talking about below is the same as that of my predecessors.
SELECT *, trim (LEADING '/' FROM 'PATH') as paths FROM 'ts _ back_pic 'limit 10
We will introduce the first LEADING, which can delete the specified characters and strings on the left.
SELECT *, trim (TRAILING '/' FROM 'PATH') as paths FROM 'ts _ back_pic 'limit 10
Second, you can delete the specified character and string on the right.
SELECT *, trim (BOTH '/' FROM 'PATH') as paths FROM 'ts _ back_pic 'limit 10
Third, you can delete specified characters and strings on both sides.
Most importantly, trim deletes multiple characters in the PHP function, but in MYSQL, it deletes strings.
To make it simple
SELECT *, trim ('PATH') as paths FROM 'ts _ back_pic 'limit 10;
Delete spaces on both sides
To provide a comprehensive feature
SELECT *, trim (BOTH '/r/N' FROM trim ('PATH') as paths FROM 'ts _ back_pic' limit 10;
Environment: Press enter after a space. you need to delete the space + press Enter.
BitsCN.com