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?

Last updated:9/22/2021 1:33:42 AM

1 Answers

Ashutosh Kumar Verma
Ashutosh Kumar Verma

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’.

What is the command used to fetch the first 5 characters of the string?

The SQL SUBSTRING function is used to fetch the first 5 characters from column ‘stuName’ in table.

What is the command used to fetch the first 5 characters of the string?

The SQL LEFT function is used to fetch the first 5 characters from column ‘stuName’ in table.

select LEFT(stuName,5) from Students;

What is the command used to fetch the first 5 characters of the string?

Answer