On Feb 10, 2:39 am, Олег Корсак <kamikaze.is.waiting....@gmail.com>
wrote:
> Hello.
> I have a model named MyModel and it has its own table named my_model (as
> an example).
>
> Is it possible to write ORM-way request to be same as this SQL:
> SELECT mo.* FROM (SELECT mi.* FROM my_model mi) AS mo WHERE mi.a=mo.a
> AND mi.b=mo.b;
>
> There is also an agregation+group by statements in subselect, but let's
> assume that we don't have them.

There might be some trick to do that, but I don't see it directly. I
think this might be a good candidate for raw SQL.

However, is the query really correct, you are referring to "mi"
outside the subselect where it is defined? And, as it reads in your
post it doesn't make much sense if the query would be allowed by your
DB vendor, as mi.a is always mo.a...

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to