By unique you mean that no id and type would be duplicated like

1,1
1,1

Yes it isn't possible for duplicate id and type in more than 1 row


On Thu, Nov 22, 2012 at 4:46 PM, Michael Dykman <mdyk...@gmail.com> wrote:

> Assuming that (id,type) is unique in the source data, that is a pretty
> elegant method:
>
> > select id from
> > (select distinct id, count(*)
> > from my_table
> > where type in (2,5)
> > group by id
> > having count(*) = 2)a;
> >
>
> --
>  - michael dykman
>  - mdyk...@gmail.com
>
>  May the Source be with you.
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql
>
>

Reply via email to