sql server 2005 - return single row when 2 records in right table
Posted
by Peanut
on Stack Overflow
See other posts from Stack Overflow
or by Peanut
Published on 2010-05-06T06:26:35Z
Indexed on
2010/05/06
6:38 UTC
Read the original article
Hit count: 274
sql-server-2005
|tables
Hi, I have two related sql server tables ... TableA and TableB.
***TableA - Columns***
TableA_ID INT
VALUE VARCHAR(100)
***TableB - Columns***
TableB_ID INT
TableA_ID INT
VALUE VARCHAR(100)
For every single record in TableA there are always 2 records in TableB. Therefore TableA has a one-to-many relationship with TableB.
How could I write a single sql statement to join these tables and return a single row for each row in TableA that includes:
- a column for the VALUE column in the first related row in table B
- a column for the VALUE column in the second related row in table B?
Thanks.
© Stack Overflow or respective owner