0

I made this code where after I type a command it updates a database. In the last query, the database thinks there's no column named leader in the organizations table, but there is (the query above uses it). What's wrong? I'm using MySQL Workbench 8.0.

mp.events.addCommand("organizations", (player, _, abb, namee, hqID) => {
const socialID = player.rgscId;
con.query("SELECT orgID FROM players WHERE scID = "+socialID+"", function (err, result) {
    resultado = result[0].orgID
    if (!abb) {
        // not relevant
    }
    else {
        con.query("SELECT playerID FROM players WHERE scID = "+socialID+"", function (err, result) {
            leaderID = result[0].playerID
            con.query("INSERT INTO organizations (abb, namee, leader, hqID) VALUES (?, ?, ?, ?)", [abb, namee, leaderID, hqID], function (err, result) {
                if (err) {
                    //not relevant
                }
            });
            con.query("UPDATE players SET player.orgID = organizations.orgID WHERE players.playerID = organizations.leader", function (err, result) {
                if (err) console.log(err)
            });
        });
    }
});

});

Shadow
  • 33,525
  • 10
  • 51
  • 64

1 Answers1

1
UPDATE players, organizations
SET player.orgID = organizations.orgID 
WHERE players.playerID = organizations.leader
Akina
  • 39,301
  • 5
  • 14
  • 25