The substring function in SQL is used to capture part of a column. The function names are not exactly the same in different databases: MySQL: SUBSTR (), SUBSTRING () Oracle: SUBSTR () SQLServer: SUBSTRING () the most common method is as follows (Here we use SUBSTR () as an example): SUBSTR (str, pos): By & lt; the substring function in str & g SQL is used to capture part of a column. The function names are not exactly the same in different databases:
MySQL: SUBSTR (), SUBSTRING ()
Oracle: SUBSTR ()
SQL Server: SUBSTRING ()
The most common method is as follows (Here we use SUBSTR () as an example ):
SUBSTR (str, pos): Select All Character starting from position. Note that this syntax is not applicable to SQL Server.
SUBSTR (str, pos, len): The Start position, select the next Characters.
SELECT
SUBSTR (COURSE_DESIGNATER, 6, 3) as "Course number"
FROM COURSES
WHERE COURSE_DESIGNATER LIKE 'excel %'
Instance 2
SELECT
UPPER (SUBSTR (lastname, 1, 1) | LOWER (SUBSTR (lastname, 2, 29 ))
AS "Lastname"
FROM Students