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