
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- MySQL query to split a column after specific characters?
- MySQL query to display a substring before a special character in a string
- Fetch the substring after last dot in MySQL
- MySQL query to return all items in a single row
- MySQL query to get a substring from a string except the last three characters?
- MySQL query to check if a string contains a value (substring) within the same row?
- MySQL query to return a string as a result of IF statement?
- How to return the nth record from MySQL query?
- How to correctly use DELIMITER in a MySQL stored procedure?
- MySQL query to return TRUE for rows having positive value?
- Create a stored procedure with delimiter in MySQL
- MySQL query to remove numbers after hyphen in a VARCHAR string with numbers
- How to update the current delimiter in MySQL?
- How to determine the current delimiter in MySQL?
- MySQL query to return all records with a datetime older than 1 week

Advertisements