cozza13
asked on
SQL HAVE statement using text
Given the following tables & Columns:
Customer
customer_id (PK)
customer_name
Order
Order_id (PK)
Customer_id (FK)
Order_Date
Order_Line
Order_id (PK) (FK)
Line_no (PK)
Item_id (FK)
Qty
Extended_price
Item
Item_id
Item_name
Item_description
Price
I am trying to write the SQL statement that retrieves the list of customers (name) who did not have any orders for product name "X" on a given date? I am having some problems
Customer
customer_id (PK)
customer_name
Order
Order_id (PK)
Customer_id (FK)
Order_Date
Order_Line
Order_id (PK) (FK)
Line_no (PK)
Item_id (FK)
Qty
Extended_price
Item
Item_id
Item_name
Item_description
Price
I am trying to write the SQL statement that retrieves the list of customers (name) who did not have any orders for product name "X" on a given date? I am having some problems
ASKER
Hi that bought up an error when trying to left join the Order_line table to the Order table
What was the error message?
--Adrian
--Adrian
ASKER
Unexpected token order requires SELECT in Statement [Select.....
it does this when I do the LEFT JOIN Order_Line ON Order.order_id=Order_Line. order_id)
it does this when I do the LEFT JOIN Order_Line ON Order.order_id=Order_Line.
What version of MySQL are you using?
--Adrian
--Adrian
ASKER
well I was trying to do it in SQL on openoffice database. The I tried it in Cryatl Reports 11 and I get the error message. "join expression not supported" using the ODBC text driver.
ASKER
I have a feeling that it can't be done with SQL on its own.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok thanks for your help
SELECT Customer.customer_name FROM ((Customer LEFT JOIN Order ON (Customer.customer_id=Orde
By using a LEFT JOIN, all of the customers will be included in the result set before the WHERE condition is considered. If the customer has an order for the product on the date specified, then Item.item_id will have a value and "WHERE Item.item_id IS NULL" will remove that customer from the final results.
--Adrian