Solved

sql join

Posted on 2013-01-26
2
283 Views
Last Modified: 2013-01-26
Hi!

I have 2 tables

products
locationID ,ItemId ,,,,,
1                    10
2                     11
2                     12
2                      13

Assets
ItemId,,,
10
11
12
13
14 ,,,,

I need to get all assets from asset for a LocationId (locationId 2 should give from assets items 11,12,13)

How  would that query look like.
0
Comment
Question by:jamppi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Expert Comment

by:Guru Ji
ID: 38822373
Select * from Assets Where ItemId IN (Select ItemId from products where locationId =2)
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 300 total points
ID: 38822387
... which will most likely by transformed to
select A.*
from Assets A join Products P on A.ItemID = P.ItemID
where P.LocationID = 2

Open in new window

by the query optimizer.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question