This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
As a matter of fact the problem does not have any relation to JDBC, rather the classical SQL. You have SQL table "table" containing two columns: "name" and "gadget". Both columns contain text strings:
Some specific name is given as the input. Please write SQL statement(s) which get the input returns list of names of the persons having set of unique gadgets equal or greater to the person which name was given as the input.
input: oleg output: anton Oleg has (computer, keyboard, mouse). Anton has more gadgets (computer, keyboard, mouse) + TV.
input: seva output: alex Seva has (phone, computer). Alex has (phone, computer) + TV + mouse. Oleg, Anton aren't printed, since both haven't phone.
input: alex output: <EMPTY> [ February 22, 2008: Message edited by: Pavel Cherkashin ]
one answer is published by me (maybe not the most efficient)
the query uses given parameter value "alex".
First i wrote the query, which selects all gadgets of given person name. Then the query, returning all gadgets, grouped by name. Then the query, which selects all names and their gadgets the given person("alex") has, but the selected person has not.
And at last count missing gadgets and if the number is 0 (no gadgets, the given person, the selected person has not), then this is a criteria for last result of name list.
Propose your queries, approaches, interesting to know. [ February 22, 2008: Message edited by: Pavel Cherkashin ]