Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql join

Posted on 2013-01-26
2
Medium Priority
?
287 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 71

Accepted Solution

by:
Qlemo earned 1200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

636 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