开发者

substring to return all values after delimiter

开发者 https://www.devze.com 2023-01-14 11:35 出处:网络
How do I get all the values after the first delimiter? In the following example I am expecting \'xyz@yahoo.com,pqr@company.com\'

How do I get all the values after the first delimiter? In the following example I am expecting 'xyz@yahoo.com,pqr@company.com'

(02:40) mysql>select substring_index('abc@hotmail.com,xyz@yahoo.com,pqr@company.com', ',',  1) as first;
+-----------------+
| first           |
+-----------------+
| abc@hotmail.com |
+-----------------+
1 row in set (0.00 sec)

(02:41) mysql>select substring_index('abc@hotmail.com,xyz@yahoo.com,pqr@company.com', ',',  -1) as last;
+-----------------+
| last            |
+-----------------+
| pqr@company.com |
+-----------------+
1 row in set (0.00 s开发者_运维问答ec)


   select substring('abc@hotmail.com,xyz@yahoo.com,pqr@company.com',
   instr('abc@hotmail.com,xyz@yahoo.com,pqr@company.com', ',') + 1) as first;
0

精彩评论

暂无评论...
验证码 换一张
取 消