> 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 -~----------~----~----~----~------~----~------~--~---