Gle*_*ift 3 javascript postgresql node.js bookshelf.js knex.js
我想用 knex 运行以下 SQL:
select * from (
(select * from foo)
union all
(select * from bar)) as biz limit 10 offset 20;
Run Code Online (Sandbox Code Playgroud)
有没有办法不用knex.raw?
knex 确实支持union和unionAll。它已记录在案
knex.select().from(function() {
this.select().from('foo')
.unionAll(function() {
this.select().from('bar')
}).as('biz')
}).limit(10).offset(20).toString()
Run Code Online (Sandbox Code Playgroud)
输出:
select * from (select * from `foo` union all select * from `bar`) as `biz` limit 10 offset 20
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2018 次 |
| 最近记录: |