mysql - How to set variable by select? -


in mssql, can use:

select @desc_out=desc01 ,      @flag_out=flag    a01   id=@id_in 

to set variable.

but in mysql, possible set variable using select?

this mssql code:

create table [dbo].[a01](     [id] [varchar](4) null,     [desc01] [varchar](20) null,     [flag] [varchar](1) null ) on [primary]  if (select object_id('p_a01')) not null drop proc p_a01; create proc p_a01 @id_in varchar(4),@desc_out varchar(20) output,@flag_out varchar(1) output begin   select @desc_out=desc01,@flag_out=flag  a01 id=@id_in end;  declare @desc_out varchar(20); declare @flag_out varchar(1);  exec p_a01 'a001',@desc_out output,@flag_out output; select  @desc_out, @flag_out; 

please suggest me same using mysql.

try this:

select @desc_out:=desc01,@flag_out:=flag  a01 id=@id_in 

ie setting variable in select in mysql need use := instead of =

also better if can declare variables before using them in select.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -