Extracting First Name and Last Name

前端 未结 3 834
余生分开走
余生分开走 2021-01-18 07:56

I have a column named Name in a table called test which has Full name and I am trying to extract First name and Last Name. So I wrote query something like this:



        
3条回答
  •  感情败类
    2021-01-18 08:24

    we may also use locate function

    SELECT Name, LEFT(Name,locate(' ',Name)-1) AS FIRST_NAME, SUBSTRING(Name,locate(' ',Name)+1,LENgth(Name)) AS LAST_NAME FROM test

提交回复
热议问题