2017-07-05 1 views
1

私はknexと、次のSQLを実行したい複数のテーブルから選択しますか?Knexは

答えて

2

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 
関連する問題