# Filtering based on 2 columns

**URL:** <https://forum.shopware.com/t/filtering-based-on-2-columns/96692>\
**Category:** Shopware 6 (English)\
**Tags:** programming\
**Created:** [14. Oktober 2022 um 12:48 UTC](https://forum.shopware.com/t/filtering-based-on-2-columns/96692 "2022-10-14T12:48:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![omar.bakerly](https://avatars.discourse-cdn.com/v4/letter/o/fbc32d/32.png) [@omar.bakerly](https://forum.shopware.com/u/omar.bakerly)\
**Post date:** [14. Oktober 2022 um 12:48 UTC](https://forum.shopware.com/t/filtering-based-on-2-columns/96692/1 "2022-10-14T12:48:10Z")

</div>

Hi everyone, I have a small question!  
Filtering entities with php criteria is very strait forward, example:  
`$criteria->addFilter(new EqualsFilter('column1', 'searchString'));`  
but it only allows us to put a string in the second parameter!  
But if I want to get all rows where two columns has the same value, the next example is what I want, but it does not work:  
`$criteria->addFilter(new EqualsFilter('column1', 'column2')); // this is not working`  
Does anyone knows how to solve it, or any work around!  
Thanks a lot 😀

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [14. Oktober 2022 um 16:29 UTC](https://forum.shopware.com/t/filtering-based-on-2-columns/96692/2 "2022-10-14T16:29:09Z")

</div>

Hello @omar.bakerly,

you can use the [platform/MultiFilter.php at trunk · shopware/platform · GitHub](https://github.com/shopware/platform/blob/trunk/src/Core/Framework/DataAbstractionLayer/Search/Filter/MultiFilter.php)

something like

```auto
$criteria->addFilter(
  new MultiFilter(
    MultiFilter::CONNECTION_AND,
    [
      new EqualsFilter('column1', 'searchString'),
      new EqualsFilter('column2', 'searchString')
    ]
  )
)

```

best regards  
abdullah

---

<div class="post-metadata">

**Author:** ![omar.bakerly](https://avatars.discourse-cdn.com/v4/letter/o/fbc32d/32.png) [@omar.bakerly](https://forum.shopware.com/u/omar.bakerly)\
**Post date:** [17. Oktober 2022 um 07:45 UTC](https://forum.shopware.com/t/filtering-based-on-2-columns/96692/3 "2022-10-17T07:45:16Z")

</div>

Thanks a lot for your help, but that is not what I want!  
In a table full of rows,  
±----±--------±--------±-----------±-----------+  
| id | column1 | column2 | created\_at | updated\_at |  
±----±--------±--------±-----------±-----------+  
| … | 55 | 55 | … | … |  
±----±--------±--------±-----------±-----------+  
| … | 16 | 27 | … | … |  
±----±--------±--------±-----------±-----------+  
| … | 62 | 62 | … | … |  
±----±--------±--------±-----------±-----------+

I simply want the rows that have column1 = column2 , but I do NOT know what is the value in the columns! it could be anything.

Thanks again for your help!

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [17. Oktober 2022 um 11:10 UTC](https://forum.shopware.com/t/filtering-based-on-2-columns/96692/4 "2022-10-17T11:10:16Z")

</div>

ok now i understand what you want to achieve.

But I’m not sure if this works with the standard Shopware DAL filters.

You could use the Shopware [platform/QueryBuilder.php at trunk · shopware/platform · GitHub](https://github.com/shopware/platform/blob/trunk/src/Core/Framework/DataAbstractionLayer/Dbal/QueryBuilder.php) to create your own query.

---

<div class="post-metadata">

**Author:** ![omar.bakerly](https://avatars.discourse-cdn.com/v4/letter/o/fbc32d/32.png) [@omar.bakerly](https://forum.shopware.com/u/omar.bakerly)\
**Post date:** [19. Oktober 2022 um 09:35 UTC](https://forum.shopware.com/t/filtering-based-on-2-columns/96692/5 "2022-10-19T09:35:15Z")

</div>

Okay, thanks a lot 😀
