I just developed some code like:
 MyModel.objects.filter(key_to_mymodel2 = MyModel2.objects.all()))
This query produce SQL:
SELECT * FROM `test_mymodel` WHERE key_to_mymodel2_id =(select `id`
from `test_mymodel2`)

It works fine on SQLLite, but in MySQL it produce error:
OperationalError: (1242, 'Subquery returns more than 1 row')
MySQL to work need query:
SELECT * FROM `test_mymodel` WHERE key_to_mymodel2_id = ANY (select
`id` from `test_mymodel2`)

Of course I can make something like:
list = MyModel2.objects.all()
res = []
for x in list:
  res += MyModel.objects.filter(key_to_mymodel2 = x)

It there any other path to solve this?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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=.


Reply via email to