需要有关如何将以下查询结果转换为以下内容的建议: 使用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;
答案 0 :(得分:0)
以下内容应该可以完成您的尝试。只是通过放置一些转义的单引号\'
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