Many thanks tim for your quick reply. You are right I meant inner join not cart product. I tried your suggested solution and instead of printing the result I use Django serializer to create an XML file. But it seems that something is taking too long and my browser just stalls. Is it because of select_related() method? I have about 200 articles per each reporter.
On Nov 7, 2:16 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > class Reporter() > > id primary key > > name > > e-mail > > ... > > > class Article() > > reporter = model.ForeignKey(reporter) > > date > > ... > > > Now I want to implement the following SQL statement in Django: > > > select name,e-mail,date from Reporter,Article where reporter = 10 > > Are you sure this is the query you want? It's a cartesian join > that will return *all* reporters associated with *every* article > written by reporter=10. I suspect you _mean_ > > select > name, email, date > from reporter r > inner join article a -- use an inner join, not cart' join > on r.id = a.reporter_id > where r.id = 10 > > which can be done with something like > > arts = Article.objects.filter(reporter_id=10).select_related() > for article in arts: > print article.reporter.name, str(article) > > -tim --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---