SQL Insert重複データのないquery

1376 ワード

    const { ID, PW } = data;
    var sql = 'INSERT INTO customers ( name, address )SELECT ?,? FROM dual WHERE NOT EXISTS ( SELECT *  FROM `customers` WHERE  name =  ? )'
    con.query(sql, [ID, PW, ID], function (err, result) {