Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004

    Red face Unanswered: SQL Data Selection Problem

    Hi, I'm having a problem when selecting data from a table where there are rows where no data exists.
    I'm searching through a list of locations to display whats in them, but if the locations are empty then the location is not displayed on the report output. i.e. it only displays rows where there is something in the location.
    I need to display even the empty locations and can't find a way of doing this and would really appreciate some help.

    Here is the code I am using:

    FROM Table1, Table2
    WHERE Table2.List_ID = '&1' AND
    ((Table1.Location_ID = Table2.Location_ID) OR
    (Table1.Location_ID IS NULL) OR
    (Table2.Location_ID IS NULL)) AND
    ((Table2.Sku_ID = Table1.Sku_ID) OR
    (Table1.Sku_ID IS NULL) OR (Table2.Sku_ID IS NULL)) AND
    ((Table1.Tag_ID = Table2.Tag_ID) OR
    (Table1.Tag_ID IS NULL) OR
    (Table2.Tag_ID IS NULL))
    GROUP BY Table1.Location_Id, Table1.Qty_On_Hand, Table1.Sku_ID, Table1.Description, Table1.Tag_ID, Table1.Batch_ID, Table1.Condition_ID, Table1.Config_ID;

  2. #2
    Join Date
    Sep 2003
    Not sure whether I got your complete question.

    You could probably look at using TSQL Outer joins "=*" or "*=" depending on your situation.

    Read up TSQL Users Guide. Chapter 4. Joins-Retrieving data from several tables.

    Hope this helps.


Posting Permissions

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