Using the SUBSTRING() MySQL Function

Using SUBSTRING() in the SELECT clause

The SUBSTRING() function is used to extract a character string from a given starting position for a given length. 

SELECT  
    SUBSTRING(course_designater,6,3) as 'Course number'                   
FROM    Courses
WHERE   course_designater LIKE 'Excel%' 
LIMIT 10

Format a column using SUBSTRING() and LOWER() and UPPER() functions

It is possible to use the MySQL LOWER() and UPPER() functions in conjunction with the SUBSTRING() function to accomplish different types of formatting.

SELECT 
  CONCAT(UPPER(SUBSTRING(lastname,1,1)),
  	LOWER(SUBSTRING(lastname,2,29)))
FROM Students
LIMIT 10

 Collapse All    Expand All
Custom Search

MySQL Information and Resources