- 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
MySQL query to return a substring after delimiter?
Use SUBSTRING() to return values after delimiter. Let us first create a table −
mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('John is good in MySQL,Sam is good in MongoDB,Mike is good in Java'); Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+-------------------------------------------------------------------+ | Title | +-------------------------------------------------------------------+ | John is good in MySQL,Sam is good in MongoDB,Mike is good in Java | +-------------------------------------------------------------------+ 1 row in set (0.00 sec)
Here is the query to return substring after delimiter.
mysql> select substring(Title, instr(Title, ',') + 1) as AfterDelimiter from DemoTable;
Output
This will produce the following output −
+---------------------------------------------+ | AfterDelimiter | +---------------------------------------------+ | Sam is good in MongoDB,Mike is good in Java | +---------------------------------------------+ 1 row in set (0.03 sec)
Advertisements