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)
Updated on: 2019-09-26T07:11:59+05:30

263 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements