Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2006
    Posts
    36

    Red face Unanswered: SQL Query ignoring null values in joins-- help

    I would like to populate a grid with data from 2 different tables.
    Table1: [PK]id(int), name(nvarchar), areaID(int)
    Table2: [PK][FK]areaID(int), areaDescription(nvarchar)

    My cerrent query is:
    SELECT Table1.id, Table1.name, Table2.areaDescription FROM Table1 INNER JOIN Table2 ON Table1.areaID = Table2.areaID

    However, sometimes the areaID in Table1 will only be populated at a later stage and therefore will be NULL in Table1. Table2 is used as a lookup table when inserting into Table1. This query therefore ommits any records in Table1 which do not have an areaID. I would like to view ALL records(ones without an areaID as well) as they would be populated in the grid and selected to be updated on web forms because they are incomplete and then subsequently assigned an areaID.

    Any help with this query would be much appreciated...
    Last edited by grooverinthesouth; 08-02-06 at 12:52.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Table1 Left Join Table2
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Mar 2006
    Posts
    36

    Cheers!

    Thanks for that. So simple.... Well thats how you learn!

Posting Permissions

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