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.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Join on one column

Author  Topic 

seanarcher
Starting Member

1 Post

Posted - 2014-09-08 : 15:44:13
I have two tables. One called Boats with fields
[LIST=1]
[*]ID
[*]SerialNo
[*]Area
[*]Company
[/LIST]
There is another table called Equipment with fields

[LIST=1]
[*]Parts
[*]ID
[/LIST]

ID is the same in Boats as the ID in Equipment (Foreign Key).There can be multiple Parts linked to ID.

I want to be able to return all the rows from Boats but only the Parts for each ID from Equipment. I dont want the other fields appearing more than once in

the query. Would be grateful for any help, thank you.

MichaelJSQL
Constraint Violating Yak Guru

252 Posts

Posted - 2014-09-08 : 16:00:37
SELECT B.* ,E.Parts
FROM Boats B
LEFT JOIN Equipment E ON E.ID = E.ID

all voats and only records that have parts in the parts table- is this what you are looking for ??
Go to Top of Page
   

- Advertisement -