我正在尝试在Teradata查询中的查询片段下面运行
router.post('/login', function(req, res) {
connection.query('SELECT user_id FROM users WHERE user_email = ? AND user_password = ?', [req.body.login, req.body.password], function(err, results) {
if (err) throw err;
if (results[0]) {
userId = results[0].user_id;
getUser("username", userId, function(err, data) {
if (err) {
console.log("ERROR : ", err);
} else {
email = data.value1;
username = data.value2;
getPosts("posts", 1, function(err, data) {
if (err) {
console.log("ERROR : ", err);
} else {
postName = data.value1;
postText = data.value2;
res.render('logged_in', {
email: email,
username: username,
pstname: postName,
psttxt: postText
}
});
}
});
} else {
res.render('index', {
validation: "failed"
});
}
});
});
我尝试了另一个但类似的
WHERE COALESCE(CAST (EXPC_DLVR_TS as date),'2020-12-31') >'2016-11-18'
对于我遇到错误的两个查询 -
WHERE CAST(COALESCE(EXPC_DLVR_TS,'12/31/2020 17:00:00.000000-08:00') as date) >'2016-11-18'
答案 0 :(得分:1)
你需要告诉Teradata' 2020-12-31'是一个约会,否则它认为它是一个字符串。只需按DATE
开头即可。在约会时总是这样做是个好习惯。
where COALESCE(CAST (EXPC_DLVR_TS as date),date '2020-12-31') > date '2016-11-18'