2010-08-31 65 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) 

回答

相關問題