Hi there

I have three linked tables, the_data (with the actual data I want),
linked with an nn_link table to a category table. Then, that category
table is linked n:1 to a display_category table.

The other way around: Each display_category entry is linked to one
category entry, which in turn is linked to several the_data entries
(n:n).

I hope that just made sense :-)

Now I want to extract all the_data entries that are in all of a list
of display_category entries (because those display_category entries
are hierarchically ordered as well). For example, when I display the
category 1->2->3 in that hierarchical order, I want to display all the
entries that are in the display_category-ies 1, 2 and 3.

What I managed to do so far though is just to extract all the entries
that are in one of those categories...

select * from
(((
    the_data
    inner join nn_link on the_data.id = nn_link.the_data_id
)
  inner join category on category.id = nn_link.category_id
)
inner join display_category on category.id = display_category.category_id
)
where display_category.id in (1, 2, 3);

I tried with a group by as well:

select * from
(((
    the_data
    inner join nn_link on the_data.id = nn_link.the_data_id
)
  inner join category on category.id = nn_link.category_id
)
inner join display_category on category.id = display_category.category_id
)
group by the_data.id
having display_category.id in (1, 2, 3) and count(the_data.id) = 3;

But unfortunately, I don't understand the results, even with help of
the "explain" output - the counts were higher than I anticipated, I
thought they would just represent the number of possible paths towards
a the_data entry...

Thanks in advance for your kind help
Guido

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to