Solved

sql join

Posted on 2013-01-26
2
279 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
2 Comments
 
LVL 11

Expert Comment

by:Guru Ji
Comment Utility
Select * from Assets Where ItemId IN (Select ItemId from products where locationId =2)
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 300 total points
Comment Utility
... 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now