Store multiple values in a variable

I am using an while loop over a select statement and it’s doing some calucaltion.Each iteration I am getting a value.But I have no idea how to store this value.Can anyone give me an idea how to do this?

I want to process everthing in mysql and then returns all values to server side.

Please post your code.
And what do you mean by “return all values to server side”? The PHP script IS server side.

[QUOTE]SET i=0;
WHILE i<total_count DO

select rate_margin*2 INTO @b from rate LIMIT i,1;

SET i = i + 1;
END WHILE;
Select @b;
[/QUOTE]

I am getting only last value

You could save it into an array.


$result_array = array();
SET i=0;
 WHILE i<total_count DO

 select rate_margin*2 INTO @b from rate LIMIT i,1;
$store_array[] = put your data here on each loop and it will build an array
 SET i = i + 1;
 END WHILE;
 Select @b; 

I don’t want to use any server side code.Everything to be done in Mysql.You showed me some PHP code.I don’t need this way.Any other ways

Temporary table is the solution :slight_smile:

Any Idea how to do is temporary table ?

Multiple values should be stored as multiple table rows. If your database doesn’t currently allow for this then the design needs to be redone.

NO need of redesiging database table.If you would have looked my question you will never say like this.I have mentioned that I need to loop through the select statement and every time I get a value from select query and I need to store this value.Temprory table is the solution for this.I have sucessfully created temp table and able to store multiple value.

Please share your solution so others facing a similar problem can benefit.