Buj*_*jji 3 mysql string substring
我的数据库中有类似于下面的文本
this is my car
how are you,doing
how is your)health
this is not(working
Run Code Online (Sandbox Code Playgroud)
当我查询数据库时,我应该从这篇文章中得到最后的话。在这个例子中
1st row should return "car"
2nd row should return "doing"
3rd row should return "health"
4th row should return "working"
Run Code Online (Sandbox Code Playgroud)
关于如何获得这个的任何想法?
谢谢你的帮助
问候
基兰
这是一个例子:
create table lastword (
id int not null auto_increment primary key,
mytext varchar(250)
) engine = myisam;
insert into lastword (mytext) values
('this is my car'),
('how are you,doing'),
('how is your)health'),
('this is not(working');
select *,
substring_index(replace(replace(replace(mytext,',',' '),')',' '),'(',' '),' ',-1) as last
from lastword
+----+---------------------+---------+
| id | mytext | last |
+----+---------------------+---------+
| 1 | this is my car | car |
| 2 | how are you,doing | doing |
| 3 | how is your)health | health |
| 4 | this is not(working | working |
+----+---------------------+---------+
4 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
如您所见,您将不得不使用大量嵌套替换来完成您的任务。
| 归档时间: |
|
| 查看次数: |
5050 次 |
| 最近记录: |