In order to extract characters from a particular or specified text field, the MID() function is used.

 

SQL MID() Syntax is as follows:

Select Mid(column_name,start,length)

From table_name;

 

Here, start indicates the starting position and length mentions the number of charecters to return.

The start parameter is mandatory to specify, but length is optional parameter. If the length is not mention, the the function returns the value from the start position of the text.

 

Let us consider the below Students table:

roll_no

Name

total_marks

(out of 600)

percentage

grade

1

Ashok

392

65.33

B

2

Chaitali

454

75.67

A

3

Smriti

502

83.60

A

4

Kaushik

337

56.10

C

 

Example:

Select Mid(name,2,3)

Form Students;

 

The result will be as follows:

Name

sho

hai

mri

aus