来自多个表的 Knex select
Knex select from multiple tables
我想 运行 跟随 SQL 和 knex:
select * from (
(select * from foo)
union all
(select * from bar)) as biz limit 10 offset 20;
有没有不用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()
输出:
select * from (select * from `foo` union all select * from `bar`) as `biz` limit 10 offset 20
我想 运行 跟随 SQL 和 knex:
select * from (
(select * from foo)
union all
(select * from bar)) as biz limit 10 offset 20;
有没有不用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()
输出:
select * from (select * from `foo` union all select * from `bar`) as `biz` limit 10 offset 20