Prev Next
SQL MID() function extracts the characters from a text field. Syntax for SQL MID() function is given below.
SQL Syntax for MID() function:
| Syntax for MID() function in SQL | SELECT MID(column_name, start, length) FROM table_name; |
Where,
- Column_name – It is the column name from which we need to extract the characters. It’s a mandatory field.
- Start – This is the starting position from where the characters need to be extracted. It’s a mandatory field and 1 is the starting character
- Length – Number of characters to be extracted. If it is left empty, it will return all characters till the end of the text. It’s an optional field.
Please consider the following table with few records as given below.
Table name (for example): student
Column names in this table: Student_ID, Student_name, City and Marks
Available records: 4 rows
