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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -