• csb5036 (9/28/2016)


    USE HandsOnOne;

    SELECT CustomerName, City, State

    FROM Customer, Address

    ORDER BY ZipCode ASC, CustomerName ASC

    When I execute this code, my return is 16 items instead of 4. Somehow, each customer is being assigned each address, giving me 4 items at each address.

    I hope they haven't been teaching you the old-style join syntax. Use the JOIN keyword, and introduce the appropriate predicate with ON. Also, make sure you alias the tables in the join and qualify each column name with a table alias.SELECT

    a.col1 AS AColumn1

    ,a.col2 AS Acolumn2

    ,b.col1 AS BColumn1

    FROM TableA a

    JOIN TableB b ON a.ID = b.ID

    The next question asks me to list the Street, City, State and ZipCode of all address without a customer associated with them. This query should return the address of 320 21st St Billings, MT 59101 because its AddressID value is 2 and there is no CustomerAddressID value of 2 in the Address table. However, I do not receive any results when I execute this query.

    What query are you referring to?

    John