Unions
Simple union using a callback
union using a callback//qb
var getResults = query
.select('title')
.from('blogs')
.whereIn('id', [1, 2, 3])
.union(function (q){
q
.select('title')
.from('blogs-archive')
.whereIn('id', [1, 2, 3])
;
})
.get();
writeDump(getResults);
//sql
SELECT `title` FROM `blogs` WHERE `id` IN (1, 2, 3) UNION SELECT `title` FROM `blogs-archive` WHERE `id` IN (1, 2, 3)Using a Query Builder instance
union all
union allOrdering union queries
union queriesMultiple union statements
union statementsLast updated
Was this helpful?