dbTalk Databases Forums  

Need Help for Parent Child Table Join Output

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss Need Help for Parent Child Table Join Output in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
chintu4uin@gmail.com
 
Posts: n/a

Default Need Help for Parent Child Table Join Output - 09-08-2010 , 10:05 AM






Hi frnds I want to know whether following thing is possible through
query

Parent Table
----------------
Pid | PField1 | PField2 | PField3 | PField4
1 A Aa Aaa Aaaa
2 B Bb Bbb Bbbb

Child Table
----------------
CPid | CField1 | CField2 | CField3
1 X Xx Xxx
1 X1 X1x X1xx
1 X2 X2x X2xx
2 Y Yy Yyy
2 Y1 Y1y Y1yy
2 Y2 Y2y Y2yy

when we create a join between this 2 table the output will be as such
Output
---------
Pid | PField1 | PField2 | PField3 | PField4 | CPid | CField1 | CField2
Quote:
CField3
1 A Aa Aaa Aaaa 1
X Xx Xxx
1 A Aa Aaa Aaaa 1
X1 X1x X1xx
1 A Aa Aaa Aaaa 1
X2 X2x X2xx
2 B Bb Bbb Bbbb 2
Y Yy Yyy
2 B Bb Bbb Bbbb 2
Y1 Y1y Y1yy
2 B Bb Bbb Bbbb 2
Y2 Y2y Y2yy


I want the output through query as below
desired output
---------
Pid | PField1 | PField2 | PField3 | PField4 | CPid | CField1 | CField2
Quote:
CField3
1 A Aa Aaa Aaaa 1
X Xx Xxx

1 X1 X1x X1xx

1 X2 X2x X2xx
2 B Bb Bbb Bbbb 2
Y Yy Yyy

2 Y1 Y1y Y1yy

2 Y2 Y2y Y2yy

Is it possible to write query to get such output..

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.