HI, Below is the sql query to get the related products of an item.
it can be helpful for many because sharing is caring.
-------------------------------------- sql query to get the related products of an item -------------------------------------
Select Inv.ITEMID, ET.NAME ,cat.NAME as Category,RlT.NAME as 'Relation Type'
,(select Itemid from inventtable where inventtable.PRODUCT = pp.RECID and inventtable.DATAAREAID='ABC' ) as 'Related Product'
from INVENTTABLE inv
inner join ECORESPRODUCTTRANSLATION as ET on Inv.PRODUCT = ET.PRODUCT AND ET.LANGUAGEID = 'en-us'
left outer join ECORESPRODUCT p on p.RECID = inv.PRODUCT
left outer join ECORESPRODUCTCATEGORY PC on pc.PRODUCT = p.RECID
left outer join ECORESCATEGORY cat on cat.RECID = pc.CATEGORY
inner join ECORESPRODUCTRELATIONTABLE as RT on RT.PRODUCT1 = p.RECID
inner join ECORESPRODUCT pp on pp.RECID = RT.PRODUCT2
inner join ECORESPRODUCTRELATIONTYPE RlT on RlT.RECID = RT.PRODUCTRELATIONTYPE
--inner join INVENTTABLE PPINV on PPINV.PRODUCT = pp.RECID
where inv.DATAAREAID='ABC'
ORDER BY Inv.ITEMID DESC
---------------------------------------------------------------------------------------------------------------------------------------------
Rgards
zeeshan adeel