Too much data will drive you crazy, if you still use selectfieldsfromtablewherelike
Too much data will drive you crazy, if you still use select fields from table where like
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 about whether 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.