Results 1 to 3 of 3
  1. #1
    AmyM is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    2

    Creating subqueries in SQL view

    I am stuck and in need of help with an access query. I am supposed to create a query that selects all the fields from a table for all the products that weigh more than 100 pounds. Then, switch to SQL view add a subquery that selects all products whose color is green.

    I have the query built, now I just need help on the SQL and adding a subquery. This is what I have:

    SELECT tblProduct.[ProductID], tblProduct.[CompanyID], tblProduct.[ProductType], tblProduct.[Price], tblProduct.[Unit], tblProduct.[Color], tblProduct.[Material], tblProduct.[Size], tblProduct.[WeightInLbs], tblProduct.[DiscountOffered]


    FROM tblProduct
    WHERE (((tblProduct.[WeightInLbs])>100))
    AND Color Green
    (Select Color
    FROM tblProduct
    WHERE Color="Green");

    The problem is the color. What is wrong with my statement about the color of the product?

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    it should be:

    Code:
    SELECT tblProduct.[ProductID], tblProduct.[CompanyID], tblProduct.[ProductType],
    tblProduct.[Price], tblProduct.[Unit], tblProduct.[Color], tblProduct.[Material], 
    tblProduct.[Size], tblProduct.[WeightInLbs], tblProduct.[DiscountOffered]
    FROM tblProduct
    WHERE (((tblProduct.[WeightInLbs])>100))
    AND tblProduct.Color IN 
    (Select tblProduct.Color
    FROM tblProduct
    WHERE tblProduct.Color="Green");
    however, if the colors are in a different table, the query will be different.

    furthermore, if you're a student and the product colors are ALSO in the products table, tell your instructor that this assignment task is aimed towards teaching you the wrong type of query skills.

  3. #3
    AmyM is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    2
    Thank you! It worked perfect! I can see what i was missing...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. startup view
    By Canaglia in forum Database Design
    Replies: 5
    Last Post: 11-03-2011, 10:23 AM
  2. LEFT/RIGHT/OUTER JOINS in a set of subqueries
    By luckycharms in forum Queries
    Replies: 1
    Last Post: 08-01-2011, 05:06 PM
  3. Replies: 1
    Last Post: 07-21-2011, 01:57 PM
  4. Replies: 1
    Last Post: 10-24-2010, 11:32 AM
  5. Creating Sort Buttons in a Header in a list view
    By marttaaayyy!! in forum Programming
    Replies: 4
    Last Post: 03-29-2010, 11:08 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums