Hi Eric,

On Sun, 2006-07-23 at 07:26 +0000, nkeric wrote:
> hi all,
> 
> I have a m2m table recording object & it's tags, here is part of the
> table data:
> 
> object_id    tag_id
> 1                15
> 1                16
> 2                15
> 3                16
> 4                15
> 4                16
> 4                17
> 
> I would like to select object_ids where tag_id=15 AND tag_id=16, that
> is "get objects which have been tagged with tag 15 & 16", the expected
> result should be 1 & 4.
> 
> How could I build this sql query?

At the moment, you need to write some custom SQL to implement this. One
possible solution is here:
http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/

It should be possible to do this through the filtering interface
eventually, but it is not implemented yet (it's a little tricky to get
right in all cases). So for now, the custom SQL solution is the only
way.

Regards,
Malcolm


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

Reply via email to