zoukankan      html  css  js  c++  java
  • 报错"sqlMessage":"Unknown column 'admin' in 'where clause'"

    在封装mysql查询适用到整个web服务器的时候遇到一个报错:

    select * from admin_user where username=admin and password=3a0238ba5f11a798d0419c46461efd73
    查询失败,原因:{"code":"ER_BAD_FIELD_ERROR","errno":1054,"sqlMessage":"Unknown column 'admin' in 'where clause'","sqlState":"42S22","index":0,"sql":"select * from admin_user where username=admin and password=3a0238ba5f11a798d0419c46461efd73"}
    

      是在使用的时候,正确的写法是:

    const {querySql}=require('../db')
    function login(username,password){
      const sql=`select * from admin_user where username='${username}' and password='${password}'`
      return querySql(sql)
    }
    
    
    module.exports={
      login
    }

    参数要加""引号

  • 相关阅读:
    CodeForces
    Codeforces 1523D Love-Hate(随机化算法,sos dp)
    CodeForces
    讲题泛做
    CF vp 新题乱做
    10.11 牛客
    10.6 牛客
    10.4 牛客
    10.9 模拟考试 题解报告
    9.18 校内模拟赛 题解报告
  • 原文地址:https://www.cnblogs.com/qingsui/p/13386320.html
Copyright © 2011-2022 走看看