mysql - SELECT not working only inside @sql statement -


i've got query works on table, , doesn't work on another: here's code (please note part of query):

set @sql = null; select group_concat(distinct concat('sum(case when columna = "'  ,columna, ' "then 1 else 0 end) "'  ,columna, ' "')) @sql table; 

i don't know why works table, when switch on table gives me error

1 row(s) affected, 1 warning(s): 1260 row 12 cut group_concat() 

if remove @sql thing , select gives me data without error...but truncates string @ point... don't know why

cause trying build dynamic query (prepared statement) should below. again case condition case when columna = columna 1 else 0 end doesn't seems valid since columna = columna true.

declare @sql varchar(200); set @sql = 'select group_concat(distinct concat(sum(case when columna = columna 1 else 0 end) columna)) (another sql query part) table'; 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -