MySQL通过分隔符提取结果

发布于 2024-10-06 21:42:02 字数 372 浏览 0 评论 0原文

我有一个快速(希望简单)的问题。我在 MySQL 数据库中存储了一些信息:

|info1=value1
|info2=value2
|info3=value3
|info4=value4
|info5=value5
|info6=value6

我需要能够从中获取一组特定的信息。我们假设这组数据位于名为 options 的表中的每条记录中。我需要能够提取 info3 值信息,这意味着我需要(对于每条记录)收到记录的“value3”部分。我不需要“|info3=”,只需要“value3”;每个记录的“value3”的实际值都不同。

I have a quick (hopefully simple) question. I have some information stored in a MySQL database:

|info1=value1
|info2=value2
|info3=value3
|info4=value4
|info5=value5
|info6=value6

I need to be able to get a certain set of information form this. Let's pretend that this set of data is in each record in a table called options. I need to be able to extract info3 value information, meaning that I need to (for every record) recieved the "value3" section of the record. I don't need "|info3=", just the "value3"; the actual value of "value3" is different for each record.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎会甘心 2024-10-13 21:42:02

你的问题很简单,好吧。

我认为答案并不相同:

select substring_index(
    substring_index(
       old_text
       ,'info3=',-1),'|',1)
from mw_text;

这应该做你想做的事。

但是,我真的希望这只是为了玩,否则,我建议您检查您的数据库设计。

You question is simple, alright.

I don't think the same can be told about the answer:

select substring_index(
    substring_index(
       old_text
       ,'info3=',-1),'|',1)
from mw_text;

This should do what you want.

BUT, I really hope that this is just for play, otherwise, I would recomend that you review your database design.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文