2 Replies Latest reply: Jun 20, 2011 1:39 PM by Daniel Garguilo RSS

    EXISTS problem

      Hi All,

       

      I would like to only load records from  Table B only if they exists in Table A. I am pretty sure i want to be using Where Exists but I can not seem to get it correct

       

      Thanks

       

      Dan

       

      TableA:

      LOAD `Master Imaging Data ID`,

      `Short Date of exam`,

      SQL SELECT *

      FROM `S:\Imaging - Data Repository\Imaging DR Summary Table.accdb`.`Tbl_ Imaging Data For Analysis`;

       

      //Load Calendar

      TableB

      LOAD DateActual as [Short Date of exam],

      SQL SELECT *

      FROM `S:\Imaging - Data Repository\Look up tables\M_Calendar\Calendar LUT.accdb`.`M_Calendar`

      WHERE EXISTS(DateActual, `Short Date of exam`);

        • EXISTS problem
          Nagaian Krishnamoorthy

          If you have multiple rows in TableA with the same 'Short Date of exam', you may not get the result you want.

           

          If there is only one row for each 'Short Date of exam' in TableA, you may use the script given below to load TableB

           

          TempTable:

          SQL SELECT *

          FROM `S:\Imaging - Data Repository\Look up tables\M_Calendar\Calendar LUT.accdb`.`M_Calendar`;

           

          TableB:

          LOAD 'Short Date of exam' as DateActual Resident TableA;

          Left Join (TableB) LOAD * Resident TempTable;