2014-04-19 80 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    | 
+-----------------------------+ 
相关问题