Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2009
    Posts
    26

    Unanswered: Querry Limits Results

    I have two tables from which I am pulling data tblCompany and tblAddress.

    Some of the companies have address data, while others have blanks remaining to be filled in. When I run my query that pulls from tblCompany and tblAddress, the query results are limited to only those companies that have address data. If I have 57 companies the query shows 26 results. There are no restriction built into the query either.

    Why does the query limit itself to results where the address data is available?

    Thanks,
    Dave

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    This is the result of running a query with an inner join. This type of join only returns records that are common to all tables in the join.

    If you want to see all companies and the addresses of those that have addresses, you need to turn the join into an outer join. This returns all the records from one side of the join (usually the left) and any records from the other side that match. If you run this type of query over your data, you should get 57 records in the returned set, 26 with addresses and 31 without.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Apr 2009
    Posts
    26
    Quote Originally Posted by weejas
    This is the result of running a query with an inner join. This type of join only returns records that are common to all tables in the join.

    If you want to see all companies and the addresses of those that have addresses, you need to turn the join into an outer join. This returns all the records from one side of the join (usually the left) and any records from the other side that match. If you run this type of query over your data, you should get 57 records in the returned set, 26 with addresses and 31 without.
    Weejas,

    Thanks, that did the trick! Thank you for your help.

    Regards,
    David

  4. #4
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    You're welcome, and thanks for letting me know!
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

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