Answers.Body: <p>You can query Matrix blocks like you are used to with all other elements</p>
  
  <pre><code>{% set blocks = element.matrixFieldHandle.type('typeHandle').field('some value').all() %}
  </code></pre>
  
  <p>Keep in mind your <code>field</code> should be a valid field handle within your block type </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-08T18:39:58.143Z
Answers.Text: I'm trying to get all entries with given field value, not all blocks.
Answers.UserDisplayName: Камен Великов
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-08T18:42:50.757Z
Answers.Text: You can either use the search parameter or do something like this https://craftcms.stackexchange.com/questions/26447/element-query-matrixfields-where
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-08T18:58:54.473Z
Answers.Text: What do you mean by search parameter?
Answers.UserDisplayName: Камен Великов
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-08T19:00:51.670Z
Answers.Text: https://docs.craftcms.com/v2/searching.html but you need to leave the field parameter blank - > you'll get all results with the search term not just the results for a certain field. Another method would be to filter for matrixBlocks directly and get their owner. It's easier but resource heavy https://github.com/craftcms/cms/blob/develop/src/web/twig/variables/CraftVariable.php#L288 `set blocks = craft.matrixBlocks.typeId(x).fieldHandle(value). all()` then loop the result and query their owner
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-08T19:14:57.843Z
Answers.Text: Or even better `entryIds = craft.matrixBlocks...... select('ownerId').column()` and then filter for those ids
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-20T08:38:38.247Z
Answers.LastActivityDate: 2018-05-20T08:51:51.330Z
Answers.LastEditDate: 2018-05-20T08:51:51.330Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I have a Matrix field and I want to be able to filter by it.</p>
  
  <p>For example I want to get all entries that has <code>matrixField.field1Type.value = {some value}.</code></p>
  
  <p>How can I do that?</p>
  
Tags: <matrix>
Title: How can I filter by Matrix field
ThreadText: # How can I filter by Matrix field
  
  (Asked by: username_0 on 2018-05-20)
  
  I have a Matrix field and I want to be able to filter by it.
  
  For example I want to get all entries that has `matrixField.field1Type.value = {some value}.`
  
  How can I do that?
  
  **Tags:** matrix
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-05-20. Score: 1
  
  You can query Matrix blocks like you are used to with all other elements
  
  ```
  {% set blocks = element.matrixFieldHandle.type('typeHandle').field('some value').all() %}
  
  ```
  
  Keep in mind your `field` should be a valid field handle within your block type
  
  > **Comments:**
  > **username_0**: I'm trying to get all entries with given field value, not all blocks.  
  > **username_1**: You can either use the search parameter or do something like this https://craftcms.stackexchange.com/questions/26447/element-query-matrixfields-where  
  > **username_0**: What do you mean by search parameter?  
  > **username_1**: https://docs.craftcms.com/v2/searching.html but you need to leave the field parameter blank - > you'll get all results with the search term not just the results for a certain field. Another method would be to filter for matrixBlocks directly and get their owner. It's easier but resource heavy https://github.com/craftcms/cms/blob/develop/src/web/twig/variables/CraftVariable.php#L288 `set blocks = craft.matrixBlocks.typeId(x).fieldHandle(value). all()` then loop the result and query their owner  
  > **username_1**: Or even better `entryIds = craft.matrixBlocks...... select('ownerId').column()` and then filter for those ids  
  
  ---
  
  