You could try with something like this:

function My_function (my_name, callback){
      stmt = db.prepare ("SELECT number_table1 from my_table1 WHERE user=?");
        stmt.bind(my_name);
        stmt.get(function(error,row){
          if(error){
            throw err;
          }
          else{
            if(row){              var stmt2 = db.prepare ("SELECT
number_table2 from my_table2 WHERE user=?");
stmt2.bind(my_name);
              stmt2.get(function(error2,row2){
                callback(number_table1 + numer_table2);
             }          })
       });
    }

I also think (but don't know which Db and driver are you using) that the
results (number_table1 and number_table2) should be somewhere in row object.

bye


On Fri, Nov 4, 2016 at 12:19 PM, <[email protected]> wrote:

> I have a question about asynchronous function. Here my function
> "My_function":
>
> function My_function (my_name, callback){
>       stmt = db.prepare ("SELECT number_table1 from my_table1 WHERE user=?");
>         stmt.bind(my_name);
>         stmt.get(function(error,row){
>           if(error){
>             throw err;
>           }
>           else{
>             if(row){
>               callback(number_table1);
>             }
>             else{
>               console.log("error");
>             }
>            }
>        });
>     }
>
> Work fine but I have 2 tables and I need do other query and I need add two 
> numbers so... in my function I need do too this query:
>
> stmt = db.prepare ("SELECT number_table2 from my_table2 WHERE user=?");
>
>
> and finally return back in my callback "number_table1 + number_table2". 
> Somebody know how to solve it? Thanks in advance.
>
> Best regards!
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules: https://gist.github.com/othiym23/9886289#file-
> moderation-policy-md
> Old group rules: https://github.com/joyent/node/wiki/Mailing-List-
> Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/nodejs/6a1a408f-92e3-4303-8264-5716591e5f99%40googlegroups.com
> <https://groups.google.com/d/msgid/nodejs/6a1a408f-92e3-4303-8264-5716591e5f99%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
ema
http://ema.codiceplastico.com <http://blog.codiceplastico.com/ema>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAKxFu7RAvFhx_y35U-Uns1WZT_oJgd9SXwB1SNf7YiN%3DEyy3Ow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to