mysql - Unknown system variable using DECLARE -
i have following mysql query.
declare reccount int default 0; set reccount=(select count(*) tables waiterid=1 , date(tdate)=date(now()));
when execute it, following error:
error code: 1193. unknown system variable 'reccount'
so, googled 'declaring variables in mysql.' appears uses declare
:
i don't understand why query doesn't execute.
i'm using mysql workbench 6.0 ce , want execute query in php.
edit:
have used default 0. if remove default 0, , change query i've written below, executes. still doesn't save result should!
set reccount=(select count(*) tables waiterid=1 , date(tdate)=date(now())); select reccount;
you have run code in procedure or function.
if use control statements have use them in function or procedure.
mysql supports if, case, iterate, leave loop, while, , repeat constructs flow control within stored programs.
Comments
Post a Comment