| Author |
Topic |
|
Kalaiselvan
Posting Yak Master
112 Posts |
Posted - 2011-07-28 : 15:19:04
|
| Table1:ProductIdProductDescriptionTables For Subscribers:Table: I_10SubscriberIdSubscriberNameProductIdTable: I_22SubscriberIdSubscriberNameProductIdTable: I_31SubscriberIdSubscriberNameProductIdTable: I_55SubscriberIdSubscriberNameProductIdTable: I_66SubscriberIdSubscriberNameProductIdTable: I_85SubscriberIdSubscriberNameProductIdI need to map ProductId with Subscribers.Table1 contains all Products with ProductIDAnd balance table is for Subscribers which has multiple ProductID's. These tables may be extended for subscribers. Here I_85 represents table name and in this 85 is subscriberID.Now from above tables i need a query to found ProductsID's SubscriberId.Ex: If Table1 has values[ProductID] [ProductDesciption] 100 Pepsi Prodcuts 101 Coke Prodcuts 102 Limca Products 103 Maaza ProductsEx: I_55 --> Table for Pepsi Subscribers --> 55 SubscriberId This table has many ProductID (ex: 100-->ProductId)SO need a Query for ProdcutId's SubscriberID and Name.Ex: If ProductId-->100 Then It must return 55-->SubsriberId Pepsi-->Subscriber's NamePlease help me in this. Because dere is no Master datas for this mapping..Regards,Kalaiselvan RLove Yourself First.... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-07-29 : 02:37:02
|
| so you want all subscribers to be listed in single row or as different rows?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Kalaiselvan
Posting Yak Master
112 Posts |
Posted - 2011-07-29 : 06:04:48
|
| Need Subscribers in single row. Ex:[PRODUCTID][SUBSCRIBERID][SUBSCRIBERNAME]For all productID's and its related SubscriberID's from multiple table which i mentioned for each Subscribers.Regards,Kalaiselvan RLove Yourself First.... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-07-29 : 11:50:40
|
| so it will be likeProduct subscribeid1 subscribername1 subscriberid2 subscribername2....?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Kalaiselvan
Posting Yak Master
112 Posts |
Posted - 2011-08-01 : 18:37:48
|
| no it will be likeProduct1, subscriberID1, SubscriberName1Product2, subscriberID1, SubscriberName1Product3, subscriberID1, SubscriberName1Product4, subscriberID1, SubscriberName1Product5, subscriberID2, SubscriberName2Product6, subscriberID2, SubscriberName2Product7, subscriberID2, SubscriberName2Product8, subscriberID2, SubscriberName2 etc....Regards,Kalaiselvan RLove Yourself First.... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-02 : 01:03:49
|
isnt it just a matter of merging all tables using union all?SELECT ProductID,SubscriberId,SubscriberNameFROM I_10UNION ALLSELECT ProductID,SubscriberId,SubscriberNameFROM I_22... ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Kalaiselvan
Posting Yak Master
112 Posts |
Posted - 2011-08-02 : 23:40:24
|
| Sir, I think you cant get my question. Union all is simple one, even I too know to do it. Am asking how to get the datas from Subscriber tables to Table 1. Table 1 has Data for ProductId and Product Description. Need to add Subscriber Id and Subscriber Name to that table. Table 1:ProductIdProductDescriptiopnFor Each ProductId need to get the SubscriberId and Description. This productId may be in any of the Subscriber Tables which I mentioned Above. Ex: It may be in I_77 OR I_55 OR I_45 etc..Need the output has If ProductId=100 and that ProductId is in I_85 table then output will be[ProductId] 100[SubscriberId] 85[SubDescription] PepsiCant able to join Table1 with I-85 directly since like I_85 there will be many tables for Subscribers. If you cant get my question still reply me will xplain you in detail.Regards,Kalaiselvan RLove Yourself First.... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-03 : 00:44:47
|
then also its same as what i told. you can join your main table with union all query likeupdate tset t.subscriberid= u.subscriberid,t.subscribername=u.subscribernamefrom [Table 1] tjoin (SELECT ProductID,SubscriberId,SubscriberNameFROM I_10UNION ALLSELECT ProductID,SubscriberId,SubscriberNameFROM I_22...)uon u.ProductID= t.ProductID ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|