Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    11

    Question Unanswered: Simple question; simple answer?

    Hello all.

    I am really driving myself nuts over this easy problem. Imagine that I am doing a simple join on two tables:

    SELECT e.firstname, j.job_name
    FROM Employee e, Jobs j
    WHERE e.job_id = j.job_id

    The problem is that if a record in the Employee table has no job_id (a feasible case in my situation), obviously that record will not be returned. Ideally, I would want the record returned whether or not a corresponding job_id exists, possibly returning "" if the job_id doesn't exist.

    I really feel like I am missing some common knowledge, so any help is great.

    Cheers!

  2. #2
    Join Date
    Jul 2003
    Location
    Hong Kong
    Posts
    56

    Re: Simple question; simple answer?

    Try the below:


    SELECT e.firstname, j.job_name
    FROM Employee e LEFT JOIN Jobs j
    ON e.job_id = j.job_id
    Cheers,
    Shev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •