How to split the name string in mysql?

后端 未结 16 1935
轮回少年
轮回少年 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 12:05

    We have stored the value of course Name and chapter name in single column ChapterName.

    Value stored like : " JAVA : Polymorphism "

    you need to retrieve CourseName : JAVA and ChapterName : Polymorphism

    Below is the SQL select query to retrieve .

           SELECT   
              SUBSTRING_INDEX(SUBSTRING_INDEX(ChapterName, ' ', 1), ' ', -1) AS 
           CourseName,
    
           REPLACE(TRIM(SUBSTR(ChapterName, LOCATE(':', ChapterName)) ),':','') AS 
           ChapterName
           FROM Courses where `id`=1;
    

    Please let me know if any question on this.

提交回复
热议问题