java - how to declare local variable in mysql -
declare my_variable varchar(250) set my_variable= select quote( lower(substring_index (doctype, ' ', 1))) dms_report limit 1 ; select my_variable;
i trying run query getting error on declare , when execute query not getting results while select quote( lower(substring_index (doctype, ' ', 1))) query returning value unable store in my_variable please me doing wrong how declare variable
please suggest me
you need parentheses around subquery:
declare my_variable varchar(250); set my_variable = (select quote(lower(substring_index(doctype, ' ', 1))) dms_report limit 1); select my_variable;
the declare
looks okay, assuming code inside programming block.
edit:
if code not inside programming block (such stored procedure), do:
select @var := quote(lower(substring_index(doctype, ' ', 1))) dms_report limit 1; select @var;
Comments
Post a Comment