gpt4 book ai didi

mysql - 子字符串返回定界符后的所有值

转载 作者:可可西里 更新时间:2023-11-01 08:00:56 24 4
gpt4 key购买 nike

如何获取第一个分隔符后的所有值?在下面的示例中,我期待 '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 sec)

最佳答案

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

关于mysql - 子字符串返回定界符后的所有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3606623/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com