Body: <p>My question is this, <strong>I want to join a matrix table to a query and look for certain values in it</strong>.  I am using this example below.  I have 2 matrix fields partsModels.model and partsModels.parts. I need to make sure that all the criteria is met before looping through any of the data.</p>
  
  <p><code>{% set entries = craft.entries.andWhere(['like', 'content.fields_myFieldHandle', 'foo']).all() %}</code></p>
  
  <p>that Robin supplied <a href="https://craftcms.stackexchange.com/questions/26152/craft-query-matrix-blocks-in-twig/26153?noredirect=1#comment34376_26153">here</a>.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-16T00:46:28.190Z
Comments.Text: I cannot find any documentation on Craft's site on how to structure or code such a query.  Has anyone done this before or used the andWhere on Matrix fields?
Comments.UserDisplayName: Vin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-17T21:14:17.997Z
Comments.Text: Seems like it be easier to just use `search`? It'll ultimately get translated to a `like` on the backend in most cases anyway. `{% set entries = craft.matrixBlocks.search('*foo*').all() %}`
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-17T21:31:31.250Z
Comments.Text: Thanks Brad.  Since that searches through all instances of foo, it will capture things I don't want in the output.  Plus I have two Matrix fields I need to compare before displaying the results.  Like here https://craftcms.stackexchange.com/questions/26183/match-matrix-fields-before-looping-through-results
Comments.UserDisplayName: Vin
Tags: <matrix><craft3>
Title: Join Matrix Fields To Query Using andWhere
ThreadText: # Join Matrix Fields To Query Using andWhere
  
  (Asked by: username_0 on 2018-05-15)
  
  My question is this, **I want to join a matrix table to a query and look for certain values in it**. I am using this example below. I have 2 matrix fields partsModels.model and partsModels.parts. I need to make sure that all the criteria is met before looping through any of the data.
  
  `{% set entries = craft.entries.andWhere(['like', 'content.fields_myFieldHandle', 'foo']).all() %}`
  
  that Robin supplied [here](https://craftcms.stackexchange.com/questions/26152/craft-query-matrix-blocks-in-twig/26153?noredirect=1#comment34376_26153).
  
  **Tags:** matrix, craft3
  
  > **Comments:**
  > **username_0**: I cannot find any documentation on Craft's site on how to structure or code such a query.  Has anyone done this before or used the andWhere on Matrix fields?  
  > **username_1**: Seems like it be easier to just use `search`? It'll ultimately get translated to a `like` on the backend in most cases anyway. `{% set entries = craft.matrixBlocks.search('*foo*').all() %}`  
  > **username_0**: Thanks username_1.  Since that searches through all instances of foo, it will capture things I don't want in the output.  Plus I have two Matrix fields I need to compare before displaying the results.  Like here https://craftcms.stackexchange.com/questions/26183/match-matrix-fields-before-looping-through-results  
  
  ---
  
  ## 0 answers
  
  