node中写接口常用到的sql语句
自己写接口不求人,node就很方便写接口,把自己写过的接口中用到的sql语句记录下来,方便日后查询
const sql = "insert into image set ?"; //一般没有传参数
const sql = "update image set account = ? where onlyId = ?"; //更新image数据库 account, onlyId 字段
db.query(sql, [account, onlyId], (err, result) => {})
const sql = "update users set email = ? where id = ?";
db.query(sql, [email, id], (err, results) => { });
const sql = "select * from users where account = ?";
db.query(sql, account, (err, results) => { });
const sql = "select * from users where id=?";
db.query(sql, req.body.id, (err, results) => { }); //通过id查询users库数据
const sql = "select * from users where status ='1' ";
db.query(sql, (err, result) => {
}); //查询status 为1的数据
版权声明:本文由Web学习之路发布,如需转载请注明出处。