在查询我有这样的一个波纹管的多行语句:如何防止select语句返回输出
set @query = '';
select @query := concat(@query, ' union (select \'',bi.param2,'\' as tableName, ',bi.param3,' id, ', bi.param4, ' text from ', bi.param2,' where ',if(TRIM(bi.param5) is null, '1=1', bi.param5),')')
from itmanagement.BasicInfo bi where bi.param2 != '';
set @query := concat(SUBSTR(@query, 7, LENGTH(@query)));
set @wholeQuery := concat('select pe.*, bi.title label
, (case when bi.param1 = \'textfield\' then pe.ElemValue else od.text end) text
from PRC_PcdElements pe join BasicInfo bi on pe.ElemType = bi.InfoID join
(',@query,")
od on bi.param2 = od.tableName and pe.ElemValue = od.id
where bi.TypeID = 3 and pe.ProcedureID = '2';");
prepare stmt1 from @wholeQuery ;
execute stmt1 ;
该查询返回两列。一个用于第一个select语句,它只是一个赋值语句,而exec语句的输出是所需的语句。
我想要阻止第一个select语句将输出的表打印出来,或者用更好的命令替换它(如果有的话)。
在此先感谢。 TG。
查看https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple- sql-query – Strawberry