title: Compare a field with a field in a related table in Prisma ORM
body: <p>I am trying to filter results by comparing one related table field with another related table field.</p>
  <p>(simplified situation)<br />
  At our institute we offer <strong>Courses</strong> that contain <strong>Lessons</strong> where a <strong>Teacher</strong> can be assigned to.<br />
  <strong>Courses</strong> are provided by <strong>Departments</strong>.<br />
  <strong>Teachers</strong> are from a <strong>Department</strong>.<br />
  We want to find all <strong>Lessons</strong> where the <strong>Teachers</strong> is from <strong>another Department</strong> than the <strong>Course</strong> that the <strong>Lesson</strong> is part of.</p>
  <p>In SQL this can be achieved like this:</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT
    * 
  FROM
    Lesson l
  JOIN Teacher t ON
    t.id = l.teacher_id
  JOIN Course c ON
    c.id = l.course_id
  WHERE 
    c.department_id &lt;&gt; t.department_id 
  </code></pre>
  <p>Currently I use a raw query using <code>Prisma.sql</code>, but I would like to use Prisma client API. I tried something like this:</p>
  <pre class="lang-js prettyprint-override"><code>return await prisma.lesson.findMany({
    where: {
      Teacher: {
        department_id: { equals: ????? }
      }
    }
  })
  </code></pre>
  <p>But I have no idea what to place at the <code>?????</code>.</p>
  <p>Is it possible to achieve this kind of filter using the Prisma client API?</p>