If I have the following (highly simplified) customer table how do I:

#1) Query for customers who *ONLY* bought apples
#2) Query for customers who bought apples *AND* bananas
#3) Query for customers who bought exactly 2 apples?

----------------------------------------------------------------------

DROP TABLE IF EXISTS Customers;
CREATE Table Customers (
        EntryID INTEGER PRIMARY KEY,
        CustomerID INT,
        Type ENUM
);

INSERT INTO Customers VALUES (NULL, 1234, 'Banana');
INSERT INTO Customers VALUES (NULL, 1234, 'Banana');

INSERT INTO Customers VALUES (NULL, 1235, 'Apple');

INSERT INTO Customers VALUES (NULL, 1236, 'Banana');

INSERT INTO Customers VALUES (NULL, 1237, 'Banana');
INSERT INTO Customers VALUES (NULL, 1237, 'Banana');
INSERT INTO Customers VALUES (NULL, 1237, 'Apple');

INSERT INTO Customers VALUES (NULL, 1238, 'Apple');
INSERT INTO Customers VALUES (NULL, 1238, 'Apple');

INSERT INTO Customers VALUES (NULL, 1239, 'Apple');
INSERT INTO Customers VALUES (NULL, 1239, 'Banana');

-- 
Scott Baker - Canby Telcom
System Administrator - RHCE - 503.266.8253
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to