What is the command used to fetch the first 5 characters of the string ?
What is the command used to fetch the first 5 characters of the string? Ravi Vishwakarma 1509 22 Sep 2021 What is the command used to fetch the first 5 characters of the string?
SQL SUBSTRING and LEFT Function:
The SQL SUBSTRING function selects the first N character from given string in column of database table.
Syntax –
SELECT SUB STRING(column_name, starting_point, length) FROM table_name ;
The other SQL LEFT function is also select or fetch the number of N character from left side of strings in column of table.
Syntax-
SELECT LEFT(column_name, length) FROM table_name ;
The following SQL statement is used to fetch the first 5 characters from given column in a table ‘Students’.
The SQL SUBSTRING function is used to fetch the first 5 characters from column ‘stuName’ in table.
The SQL LEFT function is used to fetch the first 5 characters from column ‘stuName’ in table.
select LEFT(stuName,5) from Students;