How to do SELECT ... WHERE ... IN in ClojureQL?

209 Views Asked by At

I just worked this one out. Since it's not in the documentation and needs you to dig into the source, this seemed the right venue for the solution.

In ClojureQL, how do you create a query like:

SELECT * from foo where id in (1, 5, 7);
1

There are 1 best solutions below

1
On BEST ANSWER

You need to use the in predicate from the predicates namespace, e.g.

(require '[clojureql.core :as ql])
(require '[clojureql.predicates :as pred])
(ql/select (ql/table :foo) (ql/where (pred/in :id [1 5 7])))