xorm icon indicating copy to clipboard operation
xorm copied to clipboard

can not join another query

Open localvar opened this issue 8 years ago • 4 comments

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

localvar avatar May 05 '16 09:05 localvar

Hi, Join function is not designed to support query join. I will test if we can change it to support.

lunny avatar May 05 '16 12:05 lunny

If cannot make Join and In to support query, is it possible to add new functions like: JoinQuery and InQuery?

localvar avatar May 06 '16 01:05 localvar

It could be considered.

lunny avatar May 13 '16 16:05 lunny

遇到了同样的情况,当 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

reedchan7 avatar May 21 '19 15:05 reedchan7