正常的sql的like操作:
select * from job_info where job_name like '%web%'
錯(cuò)誤的Node中的like寫法:
var name = req.query.name;
let sql = "select * from job_info where job_name like '%?%'";
db.query(sql,name, (err, rows) => {
if (err) {
} else {
}
})
正確的寫法
var name = "%" + req.query.name + "%";
let sql = "select * from job_info where job_name like ?";
db.query(sql,name, (err, rows) => {
if (err) {
} else {
}
})