On Fri, Oct 16, 2009 at 05:34:02PM -0700, Darren Duncan scratched on the wall: > I believe what you are looking for is the relational operator called DIVIDE,
Yes, this is a text-book example of a Relational "divide." If you have a table with a key column and an attribute column, and you want a list of all the keys with at least a specific set of attributes, that's basically a divide. As many others have pointed out, it is easy enough to simulate a divide when there are only a few terms, but things get much more complex (and SLOW...) when you need to match against five or six (or more) attributes. Another way to do it is a series of self-joins for each required attribute. Again, works with a small number but gets complex and slow very very quickly. For most approaches you also need custom and specific SQL statements for each number of terms. A divide operator would allow an arbitrary match. In a sense, I'm still surprised this isn't in SQL. Many-to-One key/attribute tables are extremely common, as is the need to find something with a specific set of attributes. Codd figured that out easily enough. > For example, you can do it with a nested pair of NOT EXISTS subqueries. This is the best solution I've found. Read the Celko article. The pilot/airplane example is also covered in SQL For Smarties and a number of his other books. Just be warned that the SQL can get really interesting. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Our opponent is an alien starship packed with atomic bombs. We have a protractor." "I'll go home and see if I can scrounge up a ruler and a piece of string." --from Anathem by Neal Stephenson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users