0

Below is my code.i need to get the value of 'i' as exactly as i am getting above the

'sql.query(Tosql,function(err,res){'

line,but i am not getting the same value i am getting 4,4,4,4 in this line

console.log(i +'here i am getting the i value as 4');

but i need tha above i value?

   sql.query("SELECT * FROM `table` WHERE `field1` <= '"+value+"'",function(err,rows){



                  if(rows.length >=1){
                    for(i=0;i<=rows.length;i++)
                    {

                      var Tosql = "UPDATE `table1` SET `field2` = '1' WHERE `table1`.`id` = '"+rows[i].id+"';";
                        // it results of totally 4 rows as output for above query
                        console.log(i +'here i am getting the value as 0,1,2,3');


                       sql.query(Tosql,function(err,res){
                       console.log(i +'here i am getting the i value as 4');
                      return
    })

                  }
              }
          });
Jagadeesh
  • 1,967
  • 8
  • 24
  • 47

0 Answers0