List:General Discussion« Previous MessageNext Message »
From:David Griffiths Date:October 12 2004 7:32pm
Subject:Re: subquery??
View as plain text  
Miguel,

No subquery needed

SELECT e.name, c.telephone
FROM employee e
LEFT JOIN contact c ON c.id = e.id
WHERE e.sex = 'F'

"LEFT JOIN" means there does not have to be a matching contact row to 
find an employee row, but if there is a matching row, the data will be 
returned.

I just guessed at what columns you were interested in, and assumed that 
id was the foreign key between employee and contact.

David


Miguel Loureiro wrote:

>Hello, i'm new in this.... I have 2 related tables, how can I see same
>data from main table ( simple where clause ) and if exists data from
>related table show it.......confused??
>
>Main table:         Employee: id, name,sex,age
>
>Related table:     Contact:id,telephone,employee
>
> 
>
>I want to see all female employees and, if exists the respective
>contacts...
>
> 
>
>Thanks 4 your help
>
>Best Regards
>
>Miguel Joaquim Rodrigues Loureiro
>
> - Software Development * Internet Solutions -
>
>   <http://www.hlink.pt> 
>
> 
>
>  
>

Thread
subquery??Miguel Loureiro12 Oct
  • Re: subquery??SGreen12 Oct
  • Re: subquery??David Griffiths12 Oct