SQL Server Information and Resources Bookmark this page

SQLINFO.net is a Community Service from DataExpressions makers of dbOrchestra©

Google
 

 

 

 


MySQL Code Examples

SQL DML

String Functions

Stored Procedures

SQL Views

SQL Table Basics


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

 



Copyright 2006-2007 by DataExpressions --- All Rights Reserved            dbOrchestra - MySQL home page