title: Discord.js SQL (UPDATE) Query table before do last query
body: <p>I am creating a bot that contains a &quot;!warn&quot; command that allows to report a user. the reports are recorded in a database. At the end of the code I have a query that checks if there are users that year + or = to 10 warnings.
  The problem is that if a user is warned, it's as if it's not updated in the database until the end of the code.</p>
  <pre><code>case (&quot;!warn&quot;):
              if(message.member.roles.cache.has('------------------')){
                  if(message.mentions.members.first() != undefined){
                      var select = &quot;SELECT warns FROM DiscordUsers WHERE username='&quot; + message.mentions.members.first().user.username + &quot;'&quot;;
                      con.query(select, function (err, result, fields) {
                          var temp = parseInt(result[0].warns);
                          temp++;
                          var update = &quot;UPDATE DiscordUsers SET warns = '&quot; + temp + &quot;' WHERE username='&quot; + message.mentions.members.first().user.username + &quot;'&quot;;
                          con.query(update, function (err, result) {
                          });
                      });
                      message.channel.send(&quot;succesfully warned&quot;);
                  }else{
                      message.channel.send(&quot;Uncomplete command&quot;);
                  }
              }else{
                  message.channel.send(&quot;You have been automatically reported for incorrect use of a command.&quot;);
                  autoWarn(message);
                  verfyBan(bot);
              }
          break;
  </code></pre>
  <p>Here at the execution of the code the warnings of the user are updated by 9 10, for ex.
  Then at the end of the whole program I execute this piece of code:</p>
  <pre><code>con.query(select, function (err, result, fields) {
          for (var i = 0; i &lt; result.length; i++) {
              if(result[i].warns &gt;= 10){
                  let member = message.guild.members.cache.get(result[i].id_user);
                  member.roles.remove(&quot;------------------&quot;);
                  member.roles.remove(&quot;------------------&quot;);
                  member.roles.remove(&quot;------------------&quot;);
                  member.roles.remove(&quot;------------------&quot;);
                  
              }
          }
      });
  </code></pre>
  <p>But at this point the wanr returned from the db are still worth nine, and as if at the end of all the program did all the queries in one go. can anyone help me to make sure that if one gets to 10 war is actually disabled by removing all the roles?</p>