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 |
|
Scott
Posting Yak Master
145 Posts |
Posted - 2002-10-10 : 05:21:03
|
I have 2 tables with a 1 to many relationship. I need a query that will select the joined rows but not show the repeating rows from the PK table. eg: use pubsSELECT a.au_lname, c.titleFROM dbo.authors a INNER JOINdbo.titleauthor b ON a.au_id = b.au_id INNER JOINdbo.titles c ON b.title_id = c.title_idorder by au_lnameAuthor Green has 2 books I need the lname to be listed for the first occurence but a null for the second.Green | Book title | Book Title2 Any ideas? |
|
|
smccreadie
Aged Yak Warrior
505 Posts |
Posted - 2002-10-10 : 06:15:04
|
| It depends how you are outputting the data. If you're using a client-side tool like Access or Crystal Reports, you can use groups and detail sections of a report to do this. If this is for the web or an app using VB, lookup the ADO SHAPE command.I'm sure it can be done in T-SQL someway, but I can't think of a simple way to do it. |
 |
|
|
jeroena
Yak Posting Veteran
76 Posts |
Posted - 2002-10-10 : 06:56:25
|
| Sounds like bad application design to me... Why do you want do to this?Jeroen. |
 |
|
|
Peter Dutch
Posting Yak Master
127 Posts |
Posted - 2002-10-10 : 08:52:43
|
| Why is this bad application design?? It's a very, very common design. Anyway you should not do this in your T-SQL code, but instead in the client side code. |
 |
|
|
|
|
|