I have field that contains a comma-separated list. Some old records have a comma at the beginning or end of the field. I need to remove these extra commas.
Example:<
The question was how to remove the leading and trailing characters I will show you an example with an update query.
UPDATE your_table_name
SET your_record_name = TRIM(BOTH ',' FROM your_record_name)
@codingbiz, Thank you for the website link:
Quick examples:
SELECT TRIM(BOTH ',' FROM fieldname) from tablename
SELECT TRIM(LEADING ',' FROM fieldname) from tablename
SELECT TRIM(TRAILING ',' FROM fieldname) from tablename
Thanks!
You are looking for the TRIM function.
Check this website
SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');
which in your case would be ',' instead of 'xyz'