2016-04-19 10 views
0

enter image description here> postgresデータベーステーブルを使用してログイン資格情報に電子メールとパスワードを提供しようとしています。select文の使用方法node.jsの条件

postgresデータベーステーブル。私はレコードを取得するときに私のページに200状態 を送信する必要があります。どのように条件を選んで を使用するかを親切に教えてください。いくつかの構文がありません。

 getUser : function(req, res) {  
     var pg = require('pg');  
     var conString = process.env.DATABASE_URL || "postgres://test:[email protected]: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(); 
      }); 

    }, 

答えて

1

以下の構文を試してみてください。

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

をあなたはそれが働いていた... –

+1

@Varathan Swaminathをypuを助けるために喜ん@Subburaj感謝。幸せなコーディングを持っている..それが本当にあなたを助けたら答えを受け入れてください.. – Subburaj

関連する問題