-2

I have a column named Genre in my table that contains many various comma delimited content. The data is saved in different rows in this manner:

Adventure, fantasy, sandbox, RPG elements, 
Action, FPS, horror, 
Sports, Soccer,  

I want to keep just the the first word in every row, and delete the rest. So only keep Adventure, Action, Sports.

Den.P
  • 11
  • 2

1 Answers1

0

You can use SUBSTRING_INDEX(str,delim,count) function to update the table column

update table set Genre = SUBSTRING_INDEX(Genre, ',', 1);

Please check:: https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring-index

dassum
  • 4,727
  • 2
  • 25
  • 38