Considering the need to bring the result of a second table, based on the result of the first one, how would you do it with NodeJS?
In PHP I would bring the result, and within while
I would make another query by passing the ID of the first query (I know it is not the best practice).
// List users
router.get("/users", (req, res) => {
let query = "SELECT * FROM ??";
let table = ["users"];
query = mysql.format(query, table);
connection.query(query, (err, rows) => {
if(err){
res.json({"Error": true, "Message": "Erro ao executar query do Mysql"});
}else{
res.json({"Error": false, "Message": "Successo", "Users": rows});
}
});
});
Listing User Information
let query = "SELECT * FROM ?? WHERE ?? = ?";
let table = ["users_info"];
query = mysql.format(query, table);
It would be in the case of these two, list the user and list his information that is in another table.