title: How to show records from one table that do not exist in another table
body: <p>This is a little more complicated than the usual how do I display records from one table which are not in the other.</p>
  <p>Rather, each record from one table should appear 'x' number of times in the other.</p>
  <p>The table definitions and data are as follows:</p>
  <pre><code>CREATE TABLE `time_code` (
    `ID` bigint NOT NULL AUTO_INCREMENT,
    `AREA_ID` bigint NOT NULL,
    `TIME_CODE` varchar(10) NOT NULL,
    `DESCRIPTION` varchar(255) NOT NULL,
    `FISCAL_YEAR` bigint NOT NULL,
    PRIMARY KEY (`ID`)
    )
  
  </code></pre>
  <pre><code>Id, Area, Timecode, Description, Fiscal Year
  1, 51, 101, &quot;Project A&quot;, 2022
  2, 51, 102, &quot;Project B&quot;, 2022
  </code></pre>
  <pre><code>CREATE TABLE `schedule_data` (
    `ID` bigint NOT NULL AUTO_INCREMENT,
    `AREA_ID` bigint NOT NULL,
    `TERRITORY_ID` bigint NOT NULL,
    `GROUP_ID` bigint NOT NULL,
    `TIMECODE_ID` bigint NOT NULL,
    `CALENDAR_MONTH` bigint NOT NULL,
    `FISCAL_YEAR` bigint not null,
    PRIMARY KEY (`ID`)
    )
  </code></pre>
  <pre><code>Id, Area, Territory, Group, Timecode ID, Month, Fiscal Year
  1, 51, 52, 53, 1, 2, 2022
  2, 51, 52, 54, 1, 2, 2022
  3, 51, 52, 55, 1, 2, 2022
  4, 51, 52, 53, 2, 2, 2022
  </code></pre>
  <p>In this example, time code 101 appears in each of the groups (53, 54, and 55).  Time code 102 appears only in group 53.  It is missing from groups 54 and 55.</p>
  <p>Each timecode must appear in the schedule_data table for each group (3 times, but it could vary depending upon the number of groups)</p>
  <p>How do I write a query that tells me which groups are missing time codes?</p>
  <p>Time codes apply to an entire area and the code must exist exactly once for each group...even if the values being tracked are zero.</p>
  <p>Edit to add org code table and sample records:</p>
  <pre><code>// adjacency list model
  CREATE TABLE `organization_map` (
    `ID` bigint NOT NULL AUTO_INCREMENT,
    `ORG_CODE` bigint NOT NULL,
    `NAME` varchar(255) NOT NULL,
    `PARENT_ID` bigint NOT NULL,
    `FISCAL_YEAR` bigint NOT NULL,
    PRIMARY KEY (`ID`)
  )
  </code></pre>
  <pre><code>Id, Org Code, Name, Parent Id, Fiscal Year
  51, 1, &quot;Area 1&quot;, 0, 2022
  52, 1, &quot;Territory 1&quot;, 51, 2022
  53, 5, &quot;Group 1&quot;, 52, 2022
  54, 6, &quot;Group 2&quot;, 52, 2022
  55, 7, &quot;Group 3&quot;, 52, 2022
  56, 2, &quot;Territory 2&quot;, 51, 2022
  57, 14, &quot;Group 4&quot;, 56, 2022
  58, 15, &quot;Group 5&quot;, 56, 2022
  </code></pre>