Advertisement
byu

Recursive many to many query

byu
Oct 1st, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.57 KB | None | 0 0
  1. select distinct ParentID from lego.contain where not parentid in (select childid from lego.contain);
  2.  
  3.  
  4. select ParentID, childID, Qty ,
  5.   parent.description as parent_desc,'<img src=' + parent.Image + '>' as p_picture,
  6.   child.description as child_desc,'<img src=' + child.Image + '>' as c_picture
  7. from lego.contain
  8.   join lego.part parent on parentid=parent.partid
  9.   join lego.part child on childid=child.partid
  10. where parentid='7741-1';
  11.  
  12.  
  13. select  PartID,Kind,Description,'<img src=' + Image + '>' as picture
  14. from lego.part where partid in ('3680c02','3679','3680');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement