. 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日

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本