mysql - Error 42000 Mydac TMyquery sql script wrong parse -


need mydac tmyquery not work script in navicat , sqlfiddle work tmyquery not work

set @@group_concat_max_len = 32000; select   group_concat(concat('sum(ifnull(if(s.id=',s.id,',m.qty,0),0))`',s.sizes,'`'))eval,   group_concat(concat('i.`',s.sizes,'`'))list @eval, @list from(   select distinct s.id, s.sizes   property p   join size_goods s on s.id=p.id_sizes   p.id_goods in (6,7,8)   order s.id   )s; select group_concat(p.id) @where   property p   p.id_goods in (6,7,8)   ; set @sql=concat_ws(' ',   'select g.id, g.name, g.model,',   @list,',i.total,i.price,i.cargo_payment,i.cost from(select p.id_goods id,',@eval,   ',sum(ifnull(m.qty,0))total',   ',ifnull(sum(price*qty)/sum(qty),0)price',   ',ifnull(sum(cargo_payment*qty)/sum(qty),0)cargo_payment',   ',sum(ifnull(m.qty*(m.price+m.cargo_payment),0))cost',   'from property p',   'join size_goods s on s.id=p.id_sizes',   'left join (',     'select id_property, id_actions, qty*(3-2*id_actions)qty, price, cargo_payment moves',     ') m on m.id_property=p.id',   'where p.id in (',@where,')',   'group p.id_goods',   ')i left join  goods g on g.id=i.id;'   );   select @sql; prepare stmt @sql; execute stmt; deallocate prepare stmt; 

error 42000 sql syntax nearest

the point mysql cannot prepare such sql statement. cannot use api calls preparing prepare, execute, or deallocate prepare statements. more information, please refer http://dev.mysql.com/doc/refman/5.1/en/sql-syntax-prepared-statements.html . avoid problem, should call tmyquery.open method without calling tmyquery.prepare method. result value, can use asstring property. here code example:

myquery.open; showmessage(myquery.fields[0].asstring); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo