Match Matrix Fields Before Looping Through Results I hope someone has an example or something similar they have done in Craft before.  Her is what I have.

Structure:

Section -> Flight Company

Matrix Name -> Plane Details

Matrix Block: Plane Model and Part

Matrix Fields -> Model, Part (field type: Category)

I am needing to perform this match example (preferable in crafts.entries query)before looping through the records.

Example match needed:

Model = Cessna

Part = Propx45

I need to match both those conditions before looping through the results later on in the page.  I need to make sure all the Flight Company's match that criteria before outputing the Title of the Flight Company.

How best to accomplish this?
Updated Answer

Turns out the original answer only works if you've got an single instance of a Matrix Block on the entry.  If you have multiple, it will search through all of them and return results for any block that has any of the relations you're looking for, in spite of the inclusion of and.

As of the next post-3.0.9 release, you'll be able to get relational matches from individual Matrix Block instances using a method like so:

{% set targetModel = craft.categories.id(5).one() %}
{% set targetPart = craft.categories.id(20).one() %}

{# be sure and set the field ID of the Matrix field you're interested in here %}
{% set entryIds = craft.matrixBlocks.fieldId(55).relatedTo(['and',
        { targetElement: targetModel, field: 'model' },
        { targetElement: targetPart, field: 'part' },
    ])
    .select(['ownerId'])
    .distinct()
    .column()
%}


{% set entries = craft.entries.id(entryIds).all() %}

{# display the results #}
Total: {{ entries|length }}&lt;br&gt;

&lt;ul&gt;
    {% for entry in entries %}
        &lt;li&gt;{{ entry.title }}&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;


Original Answer
Assuming the setup in your question, something like this should work:

{# These are just two examples, but get the relevant target model and part categories however you want #}

{# resolve to the "Cessna" category #}
{% set targetModel = craft.categories.id(4).one() %}

{# resolve to the "Propx45" category #}
{% set targetPart = craft.categories.id(6).one() %}

{% set entries = craft.entries.section('flightCompany').relatedTo(['and',
    { targetElement: targetModel, field: 'planeDetails.model' },
    { targetElement: targetPart, field: 'planeDetails.part' },
]).all() %}

{# display the results #}
Total: {{ entries|length }}&lt;br&gt;

&lt;ul&gt;
    {% for entry in entries %}
        &lt;li&gt;{{ entry.title }}&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;


Here's the relevant "relations" part of the docs: https://docs.craftcms.com/v3/relations.html