I want to update with Node+MySQL using a placeholder.

Asked 2 months ago, Updated 2 months ago, 5 views

I would like to get the MySQL table information as below and sort the process by pressing button.
However, if there are two placeholders, such as updatesql, I don't know how to specify them on the node side.

const checksql="SELECT* FROM users WHERE name=?";
const checkname="SELECT status FROM users WHERE name=?";

const updatesql="UPDATE users SET?WHERE?";

if(req.body.begin_button){
    var name_checked = wait query(checksql, {name:req.body.input_name});
    var status_checked = wait query(checkname, {name:req.body.input_name});

if(name_checked==0){
      var results=wait query(sql, {id:id, name:req.body.input_name, email:req.body.input_mail, start:now,status:1});
    } else {
      console.log("error");
    };
  }
  else if(req.body.finish_button){
    if(name_checked!=0){
      var results = wait query (updatesql, {end:now, status:0});
    } else {
      console.log("error");
    }
  }
  else if(req.body.start_button){
    if(status_checked==1){
      var results = wait query (updatesql, {restbegin:now, status:2});
    } else {
      console.log("error");
    };
  } else if (req.body.end_button) {
     if(status_checked==2){
        var results = wait query (updatesql, {restend:now, status:3});
     } else {
        console.log("error");
     };

  };

javascript html mysql node.js

2022-09-30 11:48

1 Answers

UPDATE users SET xxx=?, xxx=?WHERE xxx=?

I was able to solve this problem by bringing it into each If statement.
Thank you.


2022-09-30 11:48

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.