Hi Craig,

----------------you wrote-----------
> select B.name,C.name
>  from lookuptable A, user B, cat C
>  where A.user = B.id
>  and A.category = C.id
>  and A.category in (3,5);
> 
> The problem I see is that records come back where a user is in category
> 3 or
> category 5.  How do I limit records so that the selected user must have
> category entries for both 3 and 5? (not in the same entry of course)
------------------------------------


looks like your lookuptable A will contain the relation between B and C?
assuming this is true, u could try the the following sql query: 

   select B.name, C.name
  from lookuptable A, user B, cat C
  where A.user = B.id 
  and A.category = C.id
  and A.category in (3,5)
  group by A.user
  having count(A.user) > 1 

(this is because the user will have more than one listing in the lookup
table). 

let me know if this works. sometimes, mysql's lack of subqueries is a
little painful :)

cheers/erick


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to