2014-04-19 122 views

回答

0

這是一個演示,使用SUBSTRING_INDEX()函數返回文本塊的第一段,假定段落由換行符分隔。

mysql> create table t (t text); 

mysql> insert into t (t) values ('now is the time\nfor all good men'); 

mysql> select * from t; 
+----------------------------------+ 
| t        | 
+----------------------------------+ 
| now is the time 
for all good men | 
+----------------------------------+ 

mysql> select substring_index(t, '\n', 1) from t; 
+-----------------------------+ 
| substring_index(t, '\n', 1) | 
+-----------------------------+ 
| now is the time    | 
+-----------------------------+ 
相關問題