dbTalk Databases Forums  

converting a list subquery to an inner join

comp.databases comp.databases


Discuss converting a list subquery to an inner join in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
metaperl
 
Posts: n/a

Default converting a list subquery to an inner join - 07-17-2007 , 11:53 AM






Quote:
From this page: http://www.microsoft.com/technet/pro.../c0918260.mspx
We see:
SELECT CompanyName
FROM Customers
WHERE CustomerID IN
(SELECT CustomerID FROM Orders WHERE OrderDate > '1/1/95')

And I assume the following inner joins are equivalent:

SELECT CompanyName
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID
GROUP BY CompanyName

as well as:

SELECT DISTINCT CompanyName
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID

but I would like to make sure.



Reply With Quote
  #2  
Old   
Lennart
 
Posts: n/a

Default Re: converting a list subquery to an inner join - 07-18-2007 , 06:49 AM






metaperl wrote:
Quote:
From this page: http://www.microsoft.com/technet/pro.../c0918260.mspx

We see:
SELECT CompanyName
FROM Customers
WHERE CustomerID IN
(SELECT CustomerID FROM Orders WHERE OrderDate > '1/1/95')

And I assume the following inner joins are equivalent:

SELECT CompanyName
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID
GROUP BY CompanyName

as well as:

SELECT DISTINCT CompanyName
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID

but I would like to make sure.

I'm not sure what you are asking for, but the first query is obviously
not equivalent with the other two (with the info given).

/Lennart


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.