select dbo.ve_getshortpath(pp.itemid) location, pp.itemid from parts pp
join items ii on ii.contentid = pp.contentid
join parts p2 on p2.itemid = ii.itemid
--where pp.itemid = 4986
where pp.fromtype in (3, 4) and p2.fromtype = 5