Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to format as nested queries

Author  Topic 

cfgcjm
Starting Member

3 Posts

Posted - 2009-04-16 : 19:44:36
How would I reformat these two queries as nested subqueries?


SELECT OWNER.FirstName, OWNER. LastName
FROM OWNER, PURCHASE, DEALER
WHERE OWNER.SSN# = PURCHASE.SSN#
AND DEALER.City = ‘Detroit’
AND PURCHASE.PurchaseDate > 12.31.2005



SELECT OWNER.LastName, OWNER.Phone
FROM OWNER, PURCHASE
WHERE OWNER.SSN# = PURCHASE.SSN#
AND OWNER.City = ’Philadelphia’
ORDER BY OWNER.LastName ASC;

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-04-16 : 20:39:56
Why would you want to format them as nested subqueries? They can be written as JOINs and will likely perform more efficiently.
Go to Top of Page

cfgcjm
Starting Member

3 Posts

Posted - 2009-04-16 : 20:45:08
Because I'm just learning SQL and it's one of this book I got. Could you show me the nested and then the join? I'm not looking for the two queries nested together but each individual one set into a nest
Go to Top of Page
   

- Advertisement -