[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

sql join

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

873 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