Django

Code

Show
Ignore:
Timestamp:
06/12/08 08:19:37 (5 months ago)
Author:
russellm
Message:

Fixed #7327 -- Added documentation and test case for defining subqueries. Thanks, Sebastian Noack.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/db-api.txt

    r7559 r7625  
    13741374    SELECT ... WHERE id IN (1, 3, 4); 
    13751375 
     1376You can also use a queryset to dynamically evaluate the list of values 
     1377instead of providing a list of literal values. The queryset must be 
     1378reduced to a list of individual values using the ``values()`` method,  
     1379and then converted into a query using the ``query`` attribute:: 
     1380 
     1381    Entry.objects.filter(blog__in=Blog.objects.filter(name__contains='Cheddar').values('pk').query) 
     1382 
     1383This queryset will be evaluated as subselect statement:: 
     1384 
     1385    SELET ... WHERE blog.id IN (SELECT id FROM ... WHERE NAME LIKE '%Cheddar%') 
     1386 
    13761387startswith 
    13771388~~~~~~~~~~