List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:April 16 1999 12:08pm
Subject:Re: Selecting duplicates only
View as plain text  
kobasoft wrote:
> 
> Hi MySQL-ers!
> 
> Suppose you have a database of antique owners (we all know that one, I
> believe) where there's a table of sellable items:
> 
> OwnerID | ObjectTypeID
> ----------------------
> 1       | 1
> 1       | 2
> 2       | 2
> 3       | 1
>           etc...
> 
> Now what kind of select statement would I use to get a list of OwnerID's
> that are willing to sell objects with ObjectTypeID 1 AND 2 (as is the
> case with ownerID 1 in the example table above?
> 
> Greetings, Pieter van Beek

Hi Pieter

This is a often asked question on this list.
Perhaps next time you should search in one of the mail archives before.
Or get a good SQL book :)

Here we go:
SELECT
	OwnerID 
FROM 
	sellableItems AS a
	, sellableItems AS b
WHERE
	a.OwnerID=b.OwnerID
	AND a.ObjectTypeID=1
	AND b.ObjectTypeID=2

Tschau
Christian

Thread
Selecting duplicates onlykobasoft16 Apr
  • Re: Selecting duplicates onlyChristian Mack16 Apr