- Trending Categories
- 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 to select all the characters after the first 20 characters from a column in MySQL?
Let us first create a table −
mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.86 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('C is a good programming language to start'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Java is good with data structure and algorithm'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Coding is very important'); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------------------------------------------+ | Title | +------------------------------------------------+ | C is a good programming language to start | | Java is good with data structure and algorithm | | Coding is very important | +------------------------------------------------+ 3 rows in set (0.00 sec)
Following is the query to select all the characters after the first 20 characters −
mysql> select substring(Title from 20) from DemoTable;
This will produce the following output −
+-----------------------------+ | substring(Title from 20) | +-----------------------------+ | ming language to start | | ata structure and algorithm | | rtant | +-----------------------------+ 3 rows in set (0.00 sec)
Advertisements