Jump to: navigation, search

Mysql MID

From w3cyberlearnings

Contents

MySQL MID Function

This function returns the mid string. It is a synonym for SUBSTRING(Str, Position, Length).

Syntax MID

  • Str: String input
  • Position: position starts
  • Length: Length to consider
MID(Str, position, length);

Example 1

mysql> SELECT MID('she loves it',3,5);
+-------------------------+
| MID('she loves it',3,5) |
+-------------------------+
| e lov                   |
+-------------------------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT SUBSTRING('she loves it',3,5);
+-------------------------------+
| SUBSTRING('she loves it',3,5) |
+-------------------------------+
| e lov                         |
+-------------------------------+
1 row in set (0.00 sec)


Example 3

mysql> SELECT MID('she gets it',1,5);
+------------------------+
| MID('she gets it',1,5) |
+------------------------+
| she g                  |
+------------------------+
1 row in set (0.00 sec)


Related Links


Navigation
Web
SQL
MISC
References