In shopping cart product category tree is defined in nested set form as
create table artomlii (
artomaliik serial primary key,
treeparent integer references artomlii, -- parent or null if root node
categoryname char(50) );
tree maximum depth is 5.
Products in tree are defined as
create table artomadu (
artomaliik integer primary key references artomlii not null,
productid char(20) primary key not null
)
In cart home page root categories are shown using query
select * from artomlii where treeparent is null
Depending on logged-in user, some root categories can be empty, they does not contain any products in any subcategories. for this custom filter is applied to artomadu table.
This query shows empty root categories also. How to fix this so that only root categories having at least one product products in any of its child category are displayed ?
Can WITH RECURSIVE used or other idea ?