0

I have five queries, each returning count for a specific criteria which is stored into local variables. I need all the variables into one resultset.

It looks working fine in MYSQL but getting exception when retrieving form c#

SET @Totalcount := (SELECT COUNT(*) FROM Images WHERE ImageID > 9 AND name='abc') ;

SET @subTotal := (SELECT COUNT(*) FROM Images WHERE ImageID< 100 AND name='xyz');

SELECT @Totalcount , @subTotal;

Exception: ERROR [42000] [MySQL][ODBC 5.2(w) Driver][mysqld-5.6.16-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @subTotal := (SELECT COUNT(*) FROM Images WHERE ImageID=1 AND name' at line 2

What I am doing wrong? I am new to mysql so not sure what is the problem.

Munawar
  • 2,588
  • 2
  • 26
  • 29

0 Answers0