Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing from Tables 1

Status
Not open for further replies.
Apr 27, 1999
705
US
Hello,

I have two tables, Owners and Devices. The OwnerID referenced in Owners is also the same as in Devices.
I'd like to list all devices in the Devices table by the users CorpID, say Mary (2345)
I have some knowledge of INNER joins but not sure how to query.
Thanks,

fengshui1998

Owners
-------
OwnerID CorpID Name
1 1234 John
2 2345 Mary
3 4544 David
4 6644 Seth


Devices
-------
OwnerID Device SerNo
-------------------------
4 Laptop A34344
2 Laptop A45555
4 DeskTop B45455
3 Mobile M34445
3 Mobile M34446
1 Desktop B75765
2 Laptop A34666
 
Try
Code:
declare @CorpID int
set @CorpID = 2345 -- Mary

select D.Device, D.SerNo, O.CorpID, O.Name
from Owners O inner join Devices D 
on O.OwnerID = D.OwnerID where O.CorpID = @CorpID

PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top