SELECT Statement Questions

  • 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.

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply