File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes SQL Select Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Select Help" Watch "SQL Select Help" New topic

SQL Select Help

Richard Murry

Joined: Aug 20, 2007
Posts: 1
Hoping someone can help me out here . . .

I have a table that contains a number of records. It has two fields, "Starter" and "Main Course". Typical data would look like this. . .

Soup, Beef
Soup, Chicken
Salad, Pork
Soup, Beef
Salad, Chicken
Soup, Beef
Salad, Pork
etc . . .

I need to try and select all similar pairs that occur in the table more than once. For example, in the above table, I would be looking to select Soup and Beef and Salad and Pork as they occur more than twice.

Anyone help?
Chad Clites
Ranch Hand

Joined: Aug 16, 2005
Posts: 134
Off the top of my head, something like:
SELECT Starter, Main, Count(Main)AS cnt FROM my_table WHERE cnt>1;
should get you a list of any duplicates.
[ August 29, 2007: Message edited by: Chad Clites ]
I agree. Here's the link:
subject: SQL Select Help
Similar Threads
Is India a tough place to work for meat eaters?
What are you going to eat for dinner today?
Is any Chinese here ?
Feasting on Asphalt
Best eating joint in mumbai?