Hi. IMHO, the self-join is the correct solution for the given table layout (which looks reasonable to me).
Greetings, Benjamin. On Wed 2002-07-17 at 09:26:48 +0530, [EMAIL PROTECTED] wrote: [...] > > Select companyid, count(*) from CompanyServices where > > serviceid = 1 or serviceid = 2 or serviceid = 3 > > group by companyid > > having count(*) = 3 > > > > Bye and Good Luck. > > --- Arul <[EMAIL PROTECTED]> wrote: > > > Hi All > > > > > > The Table design goes like this > > > > > > Company Table > > > ---------------- > > > companyid integer > > > name varchar(100) > > > > > > > > > Services Table > > > ---------------- > > > ServiceID integer > > > Service varchar(50) > > > > > > > > > Company Services > > > ------------------- > > > companyid integer - References > > > Company(companyid) > > > serviceid integer - References > > > Services(ServiceID) [...] > > > select > > > distinct(c.companyid) , c.name > > > from > > > company c , companyservices cs1, > > > companyservices cs2, > > > companyservices cs3 > > > where > > > cs1.serviceid = 1 > > > AND cs2.serviceid = 2 > > > AND cs3.serviceid = 3 > > > AND c.companyid = cs1.companyid > > > > > > Is there any other way , i could achive the result > > > without using a self join [...] -- [EMAIL PROTECTED] --------------------------------------------------------------------- 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