 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- 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
 