gpt4 book ai didi

mysql查询在查询中添加单引号

转载 作者:行者123 更新时间:2023-11-30 00:29:40 26 4
gpt4 key购买 nike

需要有关如何将以下查询结果转换为:的建议在单引号中使用 philips、led 和 tv。

<强> insert into company_rawdata_split select 2,splits from (select NULL splits union select 'philips' union select 'led' union select 'tv') A where splits IS NOT NULL;

查询:

select concat
('insert into company_rawdata_split select ',id,',splits from (select NULL splits union select ',
replace(complaint_against ,' ', ' union select '),') A where splits IS NOT NULL;'
) ProdCatQueries from company_rawdata_new

结果

insert into company_rawdata_split select 2,splits from (select NULL splits union select philips union select led union select tv) A where splits IS NOT NULL;

最佳答案

以下内容应该可以完成您正在尝试的事情。这只是巧妙地放置一些转义单引号 \'

的问题

select concat('插入company_rawdata_split select ',id,',splits from (select NULL splits union select\'',replace(complaint_against ,' ','\' union select\''),'\') A where splits IS NOT NULL;') 来自 company_rawdata_new 的 ProdCatQueries

关于mysql查询在查询中添加单引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22603782/

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