Javascript to wait the end of a function including asynchronous MYSQL Queries from node.js?

I'm having Javascript problem to wait a function done before the below line is called. The previous function is including the Javascript MYSQL Queries calls (one of the library of node.js). Then it will be looks like:

function first() {
    /**
    * a lot processes to execute
    * including Asynchronous processes
    * like running Queries using Javascript MYSQL Library from node.js
    */
    console.log("I am the first one!");
}

first();
console.log("I am the second one!");

Then when i execute this, it happening like:

I am second one!
I am first one!

How do i make them run by keeping the queue order?

NOTE: Now for everyone who confusing the question, please jump/follow my newly created question again:
Everyone please follow/jump into this new question: Node.js MYSQL to detect the INSERT/UPDATE completeness of a Query?

Pass a callback to the 2nd function to the call to the 1st function. At the end of the 1st function, invoke theh callback:

function one(parm, callback) {
    // do something
    callback();
}
function two() {
    // do something else
}

one("my parm", two);

You would need to structure your code to use a call back

function first (callback) {

// do your stuff

callback.call();
}

first(function () { console.log("I am the second"; });

The problem you are having is very common on people who had programmed in other languages before JavaScript, such as c/java, you think JavaScript will do the following:

 Line of code1. Execute,when it's done go to the next.
 Line of code2. Execute,when it's done go to the next.
 Line of code3. Execute,when it's done go to the next.

What actually happens in JavaScript is more like:

 Line of code1. Execute
 Line of code2. Execute
 Line of code3. Execute

For JavaScript to work as you expect you need to program it in a event oriented way, that means, you need to specify which functions you want run in what specific order. To do so in JavaScript you need to make use of callbacks, for example:

 function1 (parameter A,function2){
        //...   
        function2(parameter B,function3)} 

 function2 (parameter B,function3){//...} 

 function3 (){//...} 

You could generalize more the example above, however i think leaving it like this makes it easier for understanding. You can find many articles on the web about this. The first result of a google search gave me this link.

Happy coding!