gpt4 book ai didi

MySQL - (#1242) 子查询返回超过 1 行

转载 作者:可可西里 更新时间:2023-11-01 08:38:34 25 4
gpt4 key购买 nike

我有包含 2 列的 tbl:title 和 params,值如下所示:

  • 标题:{“教学”}

  • 参数:

{ "ufield926":"34", "ufield927":"南", "ufield928":"阿拉", "ufield929":"麦加", “ufield930”:“1/1/1983”, "ufield933":"011", "ufield934":"Mub", "ufield943":"SU/HI/14", "ufield944":"平均", "ufield946":"女"}我想提取“ufield943”之后的代码:它只是 SU/HI/14,并将它与标题列中的值连接起来,如下所示:

-->教学(SU/HI/14)

这是我试过的查询:

SELECT CONCAT(title, "(", (select 
substring(
params,
locate('ufield943', params) + 12,
locate('ufield944', params) - locate('ufield943', params) - 21
) FROM tbl), ")") AS title
FROM tbl;

每次运行查询都会出现以下错误

"#1242 - Subquery returns more than 1 row"

最佳答案

我用 SUBSTRING 从标题中删除 {"..."}CHAR_LENGTH一起发挥作用。

我将 - 21 更改为 - 16 并在 (

之前添加空格
SELECT CONCAT(substring(title, 3,CHAR_LENGTH(title) - 4 ), " (", 
substring(
params,
locate('ufield943', params) + 12,
locate('ufield944', params) - locate('ufield943', params) - 16
), ")") AS Title
FROM tbl;

DEMO

关于MySQL - (#1242) 子查询返回超过 1 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56866849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com