MySQL Forums
Forum List  »  Newbie

Issue with variable initialization : Into does not reset variable if 0 records are returned
Posted by: Phil Siyam
Date: September 14, 2022 03:36PM

MySql version : 8.0.28
table1
column1
111
222


set @aa = 'ABC';

select @aa aa
Returns ABC

select column1 into @aa from table1 where column1 = 111

select @aa aa
Returns 111

select column1 into @aa from table1 where column1 = 777

select @aa aa
Returns 111 -- expected output should blank or null

Works Ok with set command

set @aa = (select column1 into @aa from table1 where column1 = 777)

select @aa aa
Returns Null -- expected output should blank or null

Options: ReplyQuote


Subject
Written By
Posted
Issue with variable initialization : Into does not reset variable if 0 records are returned
September 14, 2022 03:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.