. 2021-08-04 12:22 采纳率: 25%
浏览 307
已结题

#NodeJS项目#Mysql语句出错

数据库语句:
"select * from user where binary "+" username="+username+" and password="+password+" and type="+type;

目的:查询用户名,密码,type来判断用户是否存在and正确

报错:Error: ER_BAD_FIELD_ERROR: Unknown column 'undefined' in 'where clause'

code: 'ER_BAD_FIELD_ERROR',
errno: 1054,
sqlMessage: "Unknown column 'undefined' in 'where clause'",
sqlState: '42S22',
index: 0,
sql: 'select * from user where binary username=undefined and password=undefined and type=NaN'
}
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "登录失败".] {
code: 'ERR_UNHANDLED_REJECTION'

数据库检查了列名对而且没有空格

  • 写回答

3条回答 默认 最新

  • CSDN专家-sinJack 2021-08-04 12:46
    关注

    let sql = "select * from user where binary username="+username+" and password="+password+" and type="+type;
    你的sql中where后面为什么要加binary?
    改为:let sql = "select * from user where username="+username+" and password="+password+" and type="+type;

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 8月12日
  • 已采纳回答 8月4日
  • 创建了问题 8月4日

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料