需要有关如何将以下查询结果转换为:的建议 在单引号中使用 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/