MySQL: Read out first word of a column
Question by Guest | Last update on 2020-11-01 | Created on 2012-03-12
I am searching for a MySQL query or a corresponding function, that reads out the first word of a field from a column.
For example, if the text in a field is "Marry comes from Europe", the string "Marry" should be the MySQL result. If it is possible, I do not want to use PHP for this.
Related Topics
MySQL: Add new Column to a Table
Tutorial | 0 Comments
MySQL: Combine full text search with LIKE search for words with 3 letters
Tutorial | 2 Comments
MySQL: Write current Date or Time into Column
Tutorial | 0 Comments
MySQL: Change minimum word length for full text search
Tip | 1 Comment
Quicksort: Sort two Columns
Question | 1 Answer
MySQL: Search and Replace directly in MySQL database
Tip | 1 Comment
MySQL: Regular Expressions in MySQL queries
Info | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
What you are looking for, is the MySQL function SUBSTRING_INDEX(), which can be used in the following manner:
The function expects 3 parameters:
This example reads out the characters left from the position of the space. If you want to read out the characters standing right from the position of the space, you need to make the number negative.
Last update on 2020-11-01 | Created on 2012-03-12