Knex从多个表中select
我想用knex运行下面的SQL:
select * from ( (select * from foo) union all (select * from bar)) as biz limit 10 offset 20;
有没有办法做到这一点没有knex.raw
?
knex支持union
和unionAll
。 它被logging
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