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.
This commit is contained in:
parent
7001826d4b
commit
ec2cd1cd29
1 changed files with 8 additions and 0 deletions
|
|
@ -174,6 +174,14 @@ Queries can be nested:
|
||||||
=> ["SELECT * FROM foo WHERE (foo.a IN (SELECT a FROM bar))"]
|
=> ["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:
|
Keywords that begin with `%` are interpreted as SQL function calls:
|
||||||
|
|
||||||
```clj
|
```clj
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue