【发布时间】:2020-11-19 15:09:00
【问题描述】:
我正在使用 knex 查询生成器和 SQL Server。
所以有一个用例,我不希望将select @@rowcount 附加到update()。
这是使用 knex 的查询:
let updateQuery = knex('details').where('id', studentId).andWhere({name: Name}).update({
'value': Value,
'updated_at': new Date()});
qb生成的SQL:
update [details]
set [value] = ?, [updated_at] = ? where [id] = ? and [name] = ?; select @@rowcount
那么,我应该做哪些更改以使其不附加select @@rowcount?
【问题讨论】:
-
为什么它这样做是一个“问题”?
-
对不起,不是问题!刚刚更新了问题。
-
那么为什么它比附加
SELECT @@ROWCOUNT更重要? -
所以我正在尝试实现类似这样的 upsert。 update table1 set name = 'val2', itemname = 'val3', itemcatName = 'val4', itemQty = 'val5' where id = 'val1' if @@ROWCOUNT= 0 insert into table1(id, name) values('val1 ', 'val2')
-
看起来像你在问什么,你想做的是两件完全不同的事情。
标签: node.js sql-server knex.js