I have the following MySQL Query.
DECLARE RecCount Int Default 0;
SET RecCount=(select count(*) from tables where WaiterID=1 and date(TDate)=date(now()));
When I execute it, I get the following error:
Error Code: 1193. Unknown system variable 'RecCount'
So, I googled 'declaring variables in MySQL.' It appears that everyone uses DECLARE:
I don't understand why my query doesn't execute.
I'm using MYSQL WORKBENCH 6.0 CE and I eventually want to execute this query in PHP.
EDIT:
I have used the default as 0. If I remove the default 0, AND change the query to what I've written below, it executes. But it still doesn't save the result like it should!
SET RecCount=(select count(*) from tables where WaiterID=1 and date(TDate)=date(now()));
SELECT RecCount;