![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can MySQL SUBSTRING() function be used with FROM and FOR keywords?
The syntax of SUBSTRING() function using FROM and FOR keywords is the standard MySQL syntax.
Syntax
SUBSTRING(str FROM pos FOR len)
Here,
- str is the string from which substring would be returned.
- Pos is the starting position of substring.
- Len is the length of substring i.e. the total number of characters fetched from str.
Example
mysql> Select SUBSTRING('foobarbar' FROM 4 FOR 5); +-------------------------------------+ | SUBSTRING('foobarbar' FROM 4 FOR 5) | +-------------------------------------+ | barba | +-------------------------------------+ 1 row in set (0.00 sec)
The result set above, makes the use of FROM and FOR keywords very much clear in SUBSTRING() function.
Advertisements