Skip to Content
0
Former Member
Mar 28, 2019 at 11:57 AM

How can we write a query to retrieve distinct Products from two catalogs

103 Views

Hi Experts,

I'm having two catalogs suppose a,b.....which are having some common and different products(based on material code). Now I need to write one query to get pk's of products from both catalogs without any duplicates (based on material code).I have written the below query to get all the products from a,b.How can we modify it so that no duplicate products based on product code will get retrieved.

SELECT {p.pk} FROM {Product AS p JOIN ArticleApprovalStatus as s ON {p.approvalstatus}={s.pk} and {s:code}='approved' JOIN CatalogVersion AS cv ON {p.catalogVersion}={cv.pk} JOIN Catalog AS cat ON {cv.pk}={cat.activeCatalogVersion}} where {cat.id} = 'a' or {cat.id} = 'b'

Appreciate any responses.