Igor Tandetnik wrote: > On 2/3/2011 12:26 PM, Puneet Kishor wrote: >> On Thursday, February 3, 2011 at 11:10 AM, Scott Baker wrote: >>> INSERT INTO Customers VALUES (NULL, 1239, 'Banana'); >> Your EntryID is INTEGER PRIMARY KEY, yet you are inserting NULLs. > > That's how you tell SQLite to generate IDs automatically. >
Neat. I didn't know that. I would simply *not* insert anything for that column in order to get the automagic PK like INSERT INTO Customers (CustomerID, Type) VALUES (...) >> Your CustomerID seems like it should be unique, yet you have identical rows >> inserted. > > It's not declared unique, why do you think it should be? > Now that I know that NULL actually triggers off an automatic PK, that makes sense. However, while there might be deeper mystery to the OP, having identical rows other than the PK makes no sense to me. For what its worth, it was an "editorial" comment. >> For example, what is the difference between the first and the second row? > > EntryID. > Right. Now I know. >>> #1) Query for customers who *ONLY* bought apples >> SELECT * >> FROM Customers >> WHERE Type = 'Apple'; > > That would also report customers that bought something else besides apples. > Ahhhh... I see now. It is trickier than I thought. How about SELECT * FROM Customers WHERE Type = 'Apple' AND EntryID NOT IN (SELECT * FROM Customers WHERE Type != 'Apple'); >>> #2) Query for customers who bought apples *AND* bananas >> SELECT * >> FROM Customers >> WHERE Type = 'Apple' OR Type = 'Banana'; > > That would report customers that only bought apples, as well as those > that only bought bananas. I am tired. -- Puneet Kishor _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users