I have a table with the batting stats of all National League players from the 2020 season. When I imported the .csv file there was a bit of a formatting issue specifically with the player names
Ronald Acuna Jr.acunaro01
I obviously would like to get rid of everything after the name (starting with the ”) for all of the players spanning the 345 row table.
Some players may also be noted down as
Tony Wolters*wolteto01
or
Pablo Sandoval#sandopa01
I’ve been scouring throughout the internet and haven’t exactly been able to find the right answer, this is as close as I’ve come to maybe having an idea of a solution.
UPDATE NLHITTERS SET Name = REPLACE(Name, '%_________', ' ') WHERE Name LIKE '%_________';
Advertisement
Answer
Below will update the name column if the char is found (INSTR > 0) and get the first char up to the location of and minus 1 char (. or # or *).
UPDATE NLHITTERS SET Name = SUBSTR(Name, 0, INSTR(Name, "")-1 ) WHERE INSTR(Name, "") > 0; Result: name Ronald Acuna Jr Tony Wolters Pablo Sandoval
See example here: http://sqlfiddle.com/#!5/9a7be/9