Skip to content
This repository was archived by the owner on Mar 25, 2020. It is now read-only.

UNION Operation

Ricky Tobing edited this page Aug 17, 2013 · 3 revisions

UNION in DbQuery basically combining two SELECT Statements together.

To perform a UNION do the following:

IQuery.Select leftSelect = db.get("Student").select().columns("Name");
Cursor cursor = db.get("Employee").union(leftSelect)
                     .select().columns("Name").query();
// SQL: 
// SELECT Name FROM Student  
// UNION 
// SELECT Name FROM Employee

To perform a UNION ALL do the following:

IQuery.Select leftSelect = db.get("Student").select().columns("Name");
Cursor cursor = db.get("Employee").unionAll(leftSelect)
                     .select().columns("Name").query();
// SQL: 
// SELECT Name FROM Student  
// UNION ALL
// SELECT Name FROM Employee

Clone this wiki locally