3 Replies Latest reply on Jan 23, 2014 1:05 AM by Gingernut

    Using SQL to find records in one table which have no related records in second table

    Gingernut

      I once knew how to do this but cannot recall nor can I find on this forum but maybe I am wording it badly.

       

      I have a Customer table and a Machinetable related by CustomerID.

       

      I want to find using SQL, all customers that do not have ANY machines

       

      Have tried this in Data Viewer and get ?

       

      ExecuteSQL

      ("

      SELECT Customer.Name

      FROM Customer

      LEFT JOIN Machine ON Customer.AccNo= Machine."_AccNo"

      WHERE

      Machine.Model IS null

      ";"|";"")

       

      Hope someone can put me straight on this.

      Many thanks

       

      Cathy