Microsoft ACCESS SQL Query HElp

Discussion in 'Databases' started by ialwaysforget, Apr 21, 2010.

  1. #1
    hey i need some help
    im stuck with a database query which i have to perform using SQL in Access

    Query : Delete all items that havent been sold in 5 months

    i have only one entry in my order table which is 5 months old and not ordered. im trying to perform the query using the code below but it comes with this error "You have written a subquery that can return more than one field without using the EXISTS reserved word in the main query's FROM clause. Revise the SELECT statement of the subquery to request only one field. (Error 3306)"

    DELETE PRODUCT_ID
    FROM CD
    WHERE PRODUCT_ID NOT IN

    (SELECT DISTINCT CD.Product_ID, CD.Product_Name, CusOrder.Order_ID, CusOrder.Order_Date

    FROM CD, CusOrder, OrderCD

    WHERE CusOrder.Order_ID=OrderCD.Order_ID

    And CD.Product_ID=OrderCD.Product_ID

    And CusOrder.Order_Date< 01/12/2009);

    any help?
     
    ialwaysforget, Apr 21, 2010 IP