I have a Japanese dictionary table, the English words that correspond to the Japanese look something like this:
jap eng marks id
テクスト / text/ text book/ (n) 31112
I want to remove the leading and trailing slashes and spaces. it almost always have leading and trailing slashes but also have valid slashes separating the multiple English meanings. How can i write a query that will remove a given string if it is leading or trailing? In this case the "/ " is leading and "/" is trailing but sometimes there is multiple slashes on the end or front and sometimes with or without unnecessary spaces
so im thinking if I had some query like
set eng = REPLACE_LEADING_OR_TRAILING(" /", "", eng)
i could just query it with all the possibilities
REPLACE_LEADING_OR_TRAILING("//", "", eng)
REPLACE_LEADING_OR_TRAILING(" /", "", eng)
REPLACE_LEADING_OR_TRAILING(" / ", "", eng)
REPLACE_LEADING_OR_TRAILING("/ ", "", eng)
REPLACE_LEADING_OR_TRAILING("/", "", eng)
i know about the REPLACE() function but i can't see how i would do it with that because of the valid slashes in between multiple English meanings.
You want to use the TRIM function:
To remove spaces, just call it with no other parameter than your field/variable
SELECT TRIM(eng)
To remove another character, use this version instead:
SELECT TRIM(BOTH '/' FROM eng);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.