First - do you want to have all the tags of all the products that have
*all* of the selected tags or you want to have all the tags of all the
products that have *any* of the selected tags?

From the pseudocode it seems that you want the latter, but I am still not sure.

--
Zbyszek

On 3/15/07, Christopher H. Laco <[EMAIL PROTECTED]> wrote:
Along with my -in not working quandry, I'm also trying to figure out how
to sanely to the age old 'related things' query in a many 2 many.

The schema is roughly:

  products
    id, sku
  product_tag
    product_id, tag_id
  tags
    id, name

Given a list of selected tags, I want to find all tags of all products
that have the selected tags. In a data set/IN world, that's as easy as
(pseudo):

  select tags where tag.id in (
    select tag.id from tags join product_tag where tag in @selected
  )

But since I'm having issues with -in, trying to do this as a put join is
making my brain hurt. My first instinct is to join twice aliasing the
tags table:

  resultset({
    'tags_2.name' => [EMAIL PROTECTED]
  }, {
    distinct => 1,
    join => [
      {'map_product_tag' => 'tag'},
      {'map_product_tag' => 'tag'}
    ]
  })

What's the sanest way to accomplish this query without turning my brain
into mush?

Thanks,
-=Chris


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/




--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to