Hello, I have a really tough problem here, I can't think of a way to make this work

Imagine 2 tables, the first one is the "main" table where I keep listings of companies and "general" info about them.
In the second table, I keep 1 row for each employee and an field which points to the company (using an ID)

"main" company table
id (int) | company name (varchar) | phone (varchar) | .. more fields that doesn't really matter

"employee" table (company.id = employee.cid)
id (int) | cid (int) | name (varchar) | age (int) | email (varchar)

Now, I want to make a search which can search for 2 names and show me if there are any company that
has these names? I tried

SELECT a.* FROM company a, employee b WHERE a.id=b.cid AND b.name='joe' OR b.name='bill';

however, this would return any companies that has ONLY one Bill or one Joe .. I only want companies that
have BOTH. It also returns one row with the company per name it found, so you can imagine I got confused
when it found 2000 rows when my list of companies is 50 rows =) Basically, what I'd like to do is find the
company who has both bill and joe

I tried:
SELECT a.* FROM company a, employee b WHERE a.id=b.cid AND b.name='joe' AND b.name='bill';

But I realized this is all wrong cause the same cell cannot be both Joe and Bill =)

mysql query smallint


---------------------------------------------------------------------
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