【发布时间】:2019-09-15 22:51:46
【问题描述】:
为了允许用户使用他们的username 或email 或phonenumber 登录,我使用了这个查询:
res.post('/api/userlogin', function(req, res){
connection.query(
'SELECT * FROM users WHERE username=? OR email=? OR phonenumber=? AND password=?',
[req.body.loginfield, req.body.loginfield,req.body.loginfield, req.body.password],
function(){
...
...
//res.send
});
});
我相信这就是 mysql 的工作方式,但我想也许有一种方法可以只为多个占位符使用一个值 (req.body.loginfield) 而无需重复输入。
我在文档中找不到任何关于它的信息。
【问题讨论】: