On Thu, Jul 01, 2010 at 12:37:55PM +0100, Sam Mason wrote:
> On Thu, Jul 01, 2010 at 04:26:38AM -0700, David Fetter wrote:
> > On Wed, Jun 30, 2010 at 12:11:35AM -0700, Nick wrote:
> > > Is this the most efficient way to write this query? Id like to
> > > get a list of users that have the categorie
On Thu, Jul 01, 2010 at 04:26:38AM -0700, David Fetter wrote:
> On Wed, Jun 30, 2010 at 12:11:35AM -0700, Nick wrote:
> > Is this the most efficient way to write this query? Id like to get a
> > list of users that have the categories 1, 2, and 3?
> >
> > SELECT user_id FROM user_categories WHERE c
On Wed, Jun 30, 2010 at 12:11:35AM -0700, Nick wrote:
> Is this the most efficient way to write this query? Id like to get a
> list of users that have the categories 1, 2, and 3?
>
> SELECT user_id FROM user_categories WHERE category_id IN (1,2,3) GROUP
> BY user_id HAVING COUNT(*) = 3
>
> users_
Is this the most efficient way to write this query? Id like to get a
list of users that have the categories 1, 2, and 3?
SELECT user_id FROM user_categories WHERE category_id IN (1,2,3) GROUP
BY user_id HAVING COUNT(*) = 3
users_categories (user_id, category_id)
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
3 |