query to remove all characters after last comma in string

前端 未结 3 1359
醉酒成梦
醉酒成梦 2021-01-08 00:36

i have a mysql table with this sort of data

TACOMA, Washington, 98477

Now i have thousands of such rows. I want the data to be manipulated

3条回答
  •  [愿得一人]
    2021-01-08 00:58

    substring_index(col, ',',-1)
    

    will give the string from last index of comma to end of string

    replace(col,concat(',',substring_index(col, ',',-1)),'')
    

提交回复
热议问题