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?
53422-Sep-2021
Updated on 22-Sep-2021
Home / DeveloperSection / Forums / What is the command used to fetch the first 5 characters of the string?
Ashutosh Kumar Verma
23-Sep-2021SQL 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;