我想为此查询中的子选择分配一个别名:
(->
(korma/select* table_a)
(korma/join
(korma/subselect table_b
(korma/fields :id (korma/raw "COUNT(*) AS count"))
(korma/group :id))
(= :id :id)))
这是我要创建的 sql:
SELECT * FROM table_a LEFT JOIN (SELECT id, COUNT(*) AS count FROM table_b GROUP BY id) AS b b.id = id;
但目前 sql korma 刚刚生成:
SELECT * FROM table_a LEFT JOIN (SELECT id, COUNT(*) AS count FROM table_b GROUP BY id) id = id;