Forum

Please or Register to create posts and topics.

Remove leading comma in Places

Ed Bell posted this question in a comment on Places: Delete Unused:

I have a lot of Places that have leading commas:

", Abbeville, South Carolina, United States"

I want to remove the leading commas.

Anyone?

This seems to work:

-- List Place Names having a comma preceding the name with any number
-- of space characters around the comma
SELECT Name, TRIM(SUBSTR(TRIM(Name),2)) FROM PlaceTable
WHERE TRIM(Name) LIKE ',%'
;

-- Update Place Names to remove the leading comma and adjacent space characters
-- Repeat for multiple leading commas
UPDATE PlaceTable
SET Name = TRIM(SUBSTR(TRIM(Name),2))
WHERE TRIM(Name) LIKE ',%'
;

For reference, see Search & Replace.

Perfect!

Thanks so much.

I think I need to learn SQL. 🙂