単純なDBクエリを機能させようとしていますが、句clojure/java.jdbc
から選択できません。IN
コードは次のようになります。
(sql/with-connection db
(sql/with-query-results rows
["select f.name name
, f.id file_id
from FileCategory fc
join File f
on fc.file = f.id
where fc.category in ?
having count(1) >= ?"
[1 2] ; This is the bit which does not work.
; I have tried (to-array) and (set) too
2]
(into [] rows)))
セットをクエリに渡す方法についてのアイデアはありますか?
私の直下でクエリを実行してmysql
も問題はありません。
mysql> select f.name, f.id from FileCategory fc join File f on fc.file = f.id where fc.category in (1, 2) having count(1) >= 2;
+-----------+----+
| name | id |
+-----------+----+
| some name | 1 |
+-----------+----+
1 row in set (0.02 sec)
mysql>
違いが生じる場合は、org.clojure / clojure 1.4.0、org.clojure / java.jdbc 0.2.3、およびmysql /mysql-connector-java5.1.6を使用しています。