Hi Michael, > How do I do something like this using Django Models? > > SELECT name,birthdate FROM friends > UNION > SELECT name,birthdate FROM enemies > ORDER BY birthdate, name; > > I can't find any reference in the Django docs to getting a UNION.
The Django ORM essentially maps one DB table to one Django model class. Since, in your example, friends and enemies are two different tables i.e. two different Django model classes, the above query is not possibly using the Django Model API. However, you can execute this query as well as other complex queries using by dropping in to raw SQL. See this for an example: http://www.djangoproject.com/documentation/model-api/#executing-custom-sql -Rajesh Dhawan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

