I encountered such a problem in the offline development of big data: how to remove the slash at the end of the field data?
In SQL, you can use the TRIM() function to remove the slash at the end of the field data.
- Original table data
- after removal
Suppose you need to remove the slash at the end of the name field data, you can use the following statement:
- Query the data to remove/
SELECT TRIM(TRAILING '/' from 字段) from 表名;
- Directly update the / at the end of the table field data
UPDATE 表名SET 字段名称 = TRIM(TRAILING '/' FROM 字段名称);
This will remove the trailing slash from column_name and update it to table_name.
In the TRIM() function, the TRAILING parameter indicates that the slash is removed from the end of the field data, and '/' indicates that the character to be removed is a slash.
- Extended: remove trailing slashes
TRIM(BOTH'/' from 字段)
The BOTH parameter indicates that slashes are removed from both ends of the field data, and '/' indicates that the characters to be removed are slashes.