Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SELECT Statement Questions Expand / Collapse
Author
Message
Posted Friday, March 07, 2008 12:41 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, April 11, 2008 1:41 PM
Points: 35, Visits: 36
Hello All,

I am a Newbie to SQL Server, and just finished an extensive online course covering everything from development to optimization.
I have found that most of my questions are regarding syntax.
In the following SELECT statement, the goal is to select only beverages from Northwind DB:
-----------------
USE Northwind
SELECT ProductName
FROM Products
WHERE CategoryID IN
(SELECT CategoryID
FROM Categories
Where CategoryName = 'Beverages')
----------------------
I am unclear as to why there is a "sub SELECT" statement after WHERE Category ID IN is. The syntax is confusing to me.
Would you please describe in basic terms why this query is built the way it is. Thank you for your assistance.


Post #466076
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse