title: Retrieve records from one table related to another depending on certain criteria
body: <p>I need your SQL assistance please.
  I have one table which has unique id's and is used as a reference in a second and third table. The second table can have multiple entries for the reference id. I however only wish to retrieve the id's and details from the second table, where the reference in the third table is the same, but all the records in the second table don't have the same description.</p>
  <p>Example: (Simplified)
  Table1: (object_id is auto-increment and always unique)</p>
  <pre><code>-------------------------------
  |  object_id  |  object_name  |
  -------------------------------
  |     1234    |      Julian   |
  -------------------------------
  |     1235    |      Adrian   |
  -------------------------------
  |     1236    |      Sarah    |
  -------------------------------
  |     1237    |      Julian   |
  -------------------------------
  |     1238    |      Julian   |
  -------------------------------
  </code></pre>
  <p>Table 2: (object_id is referenced to Table 1 object_id, but account_no can be anything</p>
  <pre><code>-------------------------------
  |  object_id  |  account_no   |
  -------------------------------
  |     1234    |      1111     |
  -------------------------------
  |     1234    |      2222     |
  -------------------------------
  |     1235    |      3333     |
  -------------------------------
  |     1236    |      4444     |
  -------------------------------
  |     1236    |      5555     |
  -------------------------------
  |     1237    |      1111     |
  -------------------------------
  |     1238    |      1111     |
  -------------------------------
  </code></pre>
  <p>Table 3: (object_id is referenced to Table 1 object_id, but property_id should be the same for a specific account_no)</p>
  <pre><code>-------------------------------
  |  object_id  |  property_id  |
  -------------------------------
  |     1234    |      house_1  |
  -------------------------------
  |     1235    |      house_15 |
  -------------------------------
  |     1236    |      house_7  |
  -------------------------------
  |     1236    |      house_7  |
  -------------------------------
  |     1237    |      house_2  |
  -------------------------------
  |     1238    |      house_1  |
  -------------------------------
  </code></pre>
  <p>So the extract I need is all the rows from Table 3 where the property_id is not the same for a given account_no from table 2, with the object_id and object_name from Table 1.</p>
  <p>Result:</p>
  <pre><code>---------------------------------------------------------------
  |  object_id  |  object_name  |  account_no   |  property_id  |
  ---------------------------------------------------------------
  |     1234    |      Julian   |      1111     |      house_1  |
  ---------------------------------------------------------------
  |     1237    |      Julian   |      1111     |      house_2  |
  ---------------------------------------------------------------
  |     1238    |      Julian   |      1111     |      house_1  |
  ---------------------------------------------------------------
  </code></pre>
  <p>So the account number is the one that links the records, but they are all referenced to object_id for the property_id. I need all the records for the accounts where the property_id doesn't match, the ones with single property_id's or where there are multiple account_no but the same property_id can be ignored.</p>
  <p>So to get all the info it would be something like:</p>
  <pre><code>SELECT ob.object_id, ob.object_name, ac.account_no, pr.property_id
  FROM Table1 AS ob
  LEFT JOIN Table2 AS ac ON ob.object_id = ac.object_id
  LEFT JOIN Table3 AS pr ON ob.object_id = pr.object_id
  </code></pre>
  <p>This would return all the rows linking the account_no and the property_id to the object_id, but I only want the ones returned where the property_id don't match for a given account_no.</p>
  <p>I have tried joins and exists and various options, but I am unable to figure this one out. Any assistance would be greatly appreciated.</p>