2010-08-31 30 views
3

如何获取第一个分隔符后的所有值?在下面的例子中,我期待 'XYZ @ yahoo.com,PQR @ company.com'子串返回分隔符后的所有值

(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) 

回答

相关问题