kingjely
asked on
Mysql DECLARE variable
Hi guys,
I want to assign a value to a field
I have done this by
declare totalreferences Int default 0;
select count(transref)
INTO totalreferences
from history
WHERE storenumber = 2 and
Brandnumber = 2
I get,
> syntax error on line 1 near, 'declare totalreferences Int default 0'
If I run the query with out the first line, I get
>Error, 'undeclared variable totalreferences'
What i think Im doing -
declaring totalreferences as an int with a default of 0;
then
selecting the count(transref) , INTO totalreferences
from history
WHERE storenumber = 2 and
Brandnumber = 2
1) can i only use DECLARE inside stored procedure.
2) can someone give me an example using maybe @totalreference if this is what i need
THanks for any help
I want to assign a value to a field
I have done this by
declare totalreferences Int default 0;
select count(transref)
INTO totalreferences
from history
WHERE storenumber = 2 and
Brandnumber = 2
I get,
> syntax error on line 1 near, 'declare totalreferences Int default 0'
If I run the query with out the first line, I get
>Error, 'undeclared variable totalreferences'
What i think Im doing -
declaring totalreferences as an int with a default of 0;
then
selecting the count(transref) , INTO totalreferences
from history
WHERE storenumber = 2 and
Brandnumber = 2
1) can i only use DECLARE inside stored procedure.
2) can someone give me an example using maybe @totalreference if this is what i need
THanks for any help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rj, yea i think what im after is learning how to use variables. cool thanks !
Thanks Chris, for trying.
and Deis. i will have a look thanks !