如何使+的NodeJS PG如何使+的NodeJS PG
我想選擇欄目內容==「[email protected]」區分大小寫查詢區分大小寫查詢,
但似乎成爲選擇列=='[email protected]'?
[error: column "[email protected]" does not exist]
代碼
var userEmail = '[email protected]';
var query = 'SELECT EXISTS(SELECT * FROM "User" WHERE "Email" = "'+userEmail+'")';
dbClient.query(query, function(error, result) {
...
感謝您的回覆,你知道如何使用參數與'pg'像這樣'SELECT EXISTS(SELECT * FROM「User」WHERE 「Email」= $ userEmail)';'dbClient.query(query,$ userEmail,function(error,result){' – user1775888
假設你使用node-postgres模塊,你應該閱讀關於參數化查詢的文檔,這裏:https://github.com/brianc/node-postgres/wiki/Prepared-Statements –