Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
bplvid
Starting Member
45 Posts |
Posted - 2012-05-09 : 12:20:37
|
| I've one parent table with 7 child tables.I've a relaionship table holding parenttableid and bridgetableid.One item from parent table can be related to multiple data's in my relationship table.One(parent item) - many(bridgetableid) relationship.for eg. parent table Itemid Itemdesc. product table Productid productname relationshiptableItemid Productid 001 230001 678001 567001 874002 567002 678Now what I need is I need to get all the productname listed under a particular user and at the same time show the itemid that are related to that productid.something like thisproductname productid itemidproduct a 567 002 product b 678 002product c 230 nullproduct d 874 nullI'm doing this for the user to see all the products available and letting the user know by productname checkcheckbox based on dbvalue that relate to a particular item.Hope I was clear with my question.What kind of approach should I follow.Should I have 2 different select statements for selecting all the productname and another one for retriving productname based on itemid reference.Any good suggestion plz.Tried a lot and finally here for expert advice. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-09 : 15:51:16
|
you can use like belowSELECT p.productname, p.productid,r.itemidFROM product pLEFT JOIN relationshiptable ron r.productid = p.productid didnt understand how you will link it to user though as i cant see any user related information in product or relationship tables------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|