* Blaster
[...]
> "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';

Because you want to check two different names, you must join the employee
table twice:

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

--
Roger
sql


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