【问题标题】:How to use select statement with where condition on node.js如何在 node.js 上使用带有 where 条件的 select 语句
【发布时间】:2016-08-11 03:37:48
【问题描述】:

> 我正在尝试使用 postgres 数据库表提供包含电子邮件和密码的登录凭据。

postgres 数据库表。当我获得记录时,它应该发送 200 状态 到我的页面。查询时出错。请帮我看看如何使用 选择 where 条件。缺少一些语法。

     getUser : function(req, res) {    
        var pg = require('pg');    
        var conString = process.env.DATABASE_URL || "postgres://test:test@localhost:5432/wallet";
        var client = new pg.Client(conString);  
          client.connect();

             console.log(req.query.email_id);
             console.log(req.query.user_password);
            var query = client.query("select * from pp_user_profile where email_id ="+req.query.email_id+ "and" + "user_password=" +req.query.password);

            query.on("end", function (result) {          
                client.end();
                res.writeHead(200, {'Content-Type': 'text/plain'});
                res.write('Success');
                res.end();  
            }); 

  },

【问题讨论】:

    标签: angularjs node.js postgresql


    【解决方案1】:

    试试下面的语法:

    "select * from pp_user_profile where email_id  = '"+req.query.email_id+"' and user_password= '"+req.query.password+"'";
    

    【讨论】:

    • @Varathan Swaminath 很高兴为您提供帮助。祝您编码愉快..如果它真的对您有帮助,请接受答案..
    猜你喜欢
    • 2021-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 2012-01-26
    • 2014-07-29
    • 2013-07-07
    相关资源
    最近更新 更多