Reputation: 32346
How do I get all the values after the first delimiter? In the following example I am expecting '[email protected],[email protected]'
(02:40) mysql>select substring_index('[email protected],[email protected],[email protected]', ',', 1) as first;
+-----------------+
| first |
+-----------------+
| [email protected] |
+-----------------+
1 row in set (0.00 sec)
(02:41) mysql>select substring_index('[email protected],[email protected],[email protected]', ',', -1) as last;
+-----------------+
| last |
+-----------------+
| [email protected] |
+-----------------+
1 row in set (0.00 sec)
Upvotes: 3
Views: 3049
Reputation: 25380
select substring('[email protected],[email protected],[email protected]',
instr('[email protected],[email protected],[email protected]', ',') + 1) as first;
Upvotes: 5