我的表中有一列名为Genre的列,其中包含许多用逗号分隔的内容。 数据以这种方式保存在不同的行中:
Adventure, fantasy, sandbox, RPG elements,
Action, FPS, horror,
Sports, Soccer,
我只想保留每行的第一个单词,然后删除其余的单词。所以只保留冒险,动作和运动。
答案 0 :(得分:0)
您可以使用SUBSTRING_INDEX(str,delim,count)函数更新表列
update table set Genre = SUBSTRING_INDEX(Genre, ',', 1);
请检查:: https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring-index