MySQL query to extract first word from a field

后端 未结 4 521
夕颜
夕颜 2021-02-03 19:20

I would like to run a query that returns the first word only from a particular field, this field has multiple words separated by spaces, I assume I may need to carry out some re

4条回答
  •  难免孤独
    2021-02-03 20:05

    Here you go :)

    SELECT SUBSTRING_INDEX( `field` , ' ', 1 ) AS `field_first_word`
    FROM `your_table`
    

提交回复
热议问题