groovy 灵活搜索包含产品类别

e5nszbig  于 2022-11-01  发布在  其他
关注(0)|答案(1)|浏览(140)

我试图创建一个灵活的搜索取决于一个特定的类别。
我想做的是,吸引超级类别代码'3741'的产品但产品必须只属于这个类别,没有子类别或超级类别。

这是我的灵活查询

select {prod.pk}, {prod.code}, {cat.code},{cat.name} from
 {Product as prod
     join CategoryProductRelation as level3 on {level3.target} = {prod.pk}
     join CategoryCategoryRelation as level2 on {level2.target} = {level3.source}
     join CategoryCategoryRelation as level1 on {level1.target} = {level2.source}
     join Category as cat on {cat.pk} = {level1.source}
 }
 where {cat.pk} = '8796117467278'

如果产品具有我的类别,则此查询将显示所有产品。
谢谢你的回答。

vsikbqxv

vsikbqxv1#

以下查询可根据需要进一步修改。

SELECT {p:code} product, {c:code} Category FROM {Product AS p JOIN CatalogVersion AS cv ON {p:catalogVersion} = {cv:pk} JOIN CategoryProductRelation as cpr ON {cpr:target}={p:pk} JOIN Category as c ON {c:pk}={cpr.source}} 
WHERE {cv:version} = 'Online' AND {p:code}=100029544

相关问题