From ec2cd1cd29c65e6fe3cba6b5cfe37c5be15f5838 Mon Sep 17 00:00:00 2001 From: Donald Ball Date: Tue, 25 Aug 2015 11:25:05 -0400 Subject: [PATCH] Document the correct use of the :union clause My co-workers and I naively expected to include the :union in the primary query, not as a container. This is a good representation, but merits explanation. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index cd2cb6a..01365a6 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,14 @@ Queries can be nested: => ["SELECT * FROM foo WHERE (foo.a IN (SELECT a FROM bar))"] ``` +Queries may be united within a :union or :union-all keyword: + +```clj +(sql/format {:union [(-> (select :*) (from :foo)) + (-> (select :*) (from :bar))]}) +=> ["(SELECT * FROM foo) UNION (SELECT * FROM bar)"] +``` + Keywords that begin with `%` are interpreted as SQL function calls: ```clj