【发布时间】:2019-10-08 09:35:54
【问题描述】:
我想选择小于或等于column2 的column1 数据。然而,当我尝试使用<= 时,我得到一个空结果,尽管column1 中的数据小于column2。
我的代码:
router.get('/', function(req, res, next) {
db('items').select().where('column1', '<=', 'column2').then((notify)=>{
console.log(notify)
res.render('index', { title: 'Express', notify:notify })
})
})
结果:
[]
如你所见,它是空的!
如果我使用大于或等于:
.where('column1', '>=', 'column2')
我得到了所有的行:
[ RowDataPacket {
column_id: 1,
column1: 99,
column2: 10, },
RowDataPacket {
column_id: 2,
column1: 10,
column2: 10, },
RowDataPacket {
column_id: 3,
column1: 29,
column2: 12,} ]
这是为什么?
【问题讨论】:
-
你能检查/记录从 knex 返回的查询吗?