xorm
xorm copied to clipboard
can not join another query
I'm using mysql driver and need to join the result of another query, for example:
tran.Join("LEFT", "(SELECT template_id Id, COUNT(1) Heat FROM Ad GROUP BY template_id) AS h", "t.TEMPLATE_ID = h.Id")
but xorm generate wrong sql by add ` to the sub query
This issue may also affect the 'In' function
Hi,
Join
function is not designed to support query join. I will test if we can change it to support.
If cannot make Join
and In
to support query, is it possible to add new functions like: JoinQuery
and InQuery
?
It could be considered.
遇到了同样的情况,当 LEFT OUTER JOIN
的时候:
LEFT OUTER JOIN `(SELECT pkg_id, COUNT(1) AS count FROM versions WHERE deleted_at = '0001-01-01 00:00:00' GROUP BY (pkg_id))` AS `v`
的时候,就会报
Incorrect table name '(SELECT pkg_id, COUNT(1) AS count FROM versions WHERE deleted_at = '0001-01-01 00:00:00' GR'
请问现在有什么解决方案么? @lunny