you are at Encyclopedia of SQL >> MID()
MID(`column_name`,start[,length])
Function returns text string from `column_name` starting from start position.
If there is provided third parameter, there would be returned specified length of characters
starting from start position.
Syntax
SELECT MID(`column_name`,start[,length])
FROM `table_name`
Example
Display first three characters of name and surname
name | surname | age |
Paweł | Kowalski | 3 |
Piotr | Janik | 7 |
Michał | Nowak | 13 |
query
SELECT MID(`name`,1,3)
AS short_name,MID(`surname`,1,3)
AS short_surname
FROM `people`
result
name | surname |
Paw | Kow |
Pio | Jan |
Mic | Now |
[ wróć na górę strony ]