How to split the name string in mysql?

后端 未结 16 2311
轮回少年
轮回少年 2020-11-22 11:44

How to split the name string in mysql ?

E.g.:

name
-----
Sachin ramesh tendulkar
Rahul dravid

Split the name like firstname

16条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 11:48

    You can use bewlo one also:

    SELECT SUBSTRING_INDEX(Name, ' ', 1) AS fname,
    SUBSTRING_INDEX(SUBSTRING_INDEX(Name,' ', 2), ' ',-1) AS mname,
    SUBSTRING_INDEX(Name, ' ', -1) as lname FROM mytable;
    

提交回复
热议问题