# How to use IN operator in matillion

**URL:** <https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188>\
**Category:** Matillion ETL\
**Created:** [June 1, 2023, 7:40am UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188 "2023-06-01T07:40:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivamsachan303](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@shivamsachan303](https://matillioncommunity.discourse.group/u/shivamsachan303)\
**Post date:** [June 1, 2023, 7:40am UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/1 "2023-06-01T07:40:51Z")

</div>

I have two data sources D1 and D2 and i want to filter data from D1 using condition :- SELECT \* FROM D1 where D1.customer\_key in (select customer\_key from D2)

---

<div class="post-metadata">

**Author:** ![ASD](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/asd/32/1323_2.png) [@ASD](https://matillioncommunity.discourse.group/u/ASD)\
**Post date:** [June 1, 2023, 9:03am UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/2 "2023-06-01T09:03:12Z")

</div>

Hi [@shivamsachan303](https://matillioncommunity.discourse.group/u/shivamsachan303)​

The query syntax that you wrote seems to be working.

You just have to use a SQL query component that is taking data from both tables (D1-D2) and you should be able to do it in Matillion.

---

<div class="post-metadata">

**Author:** ![ramalingam](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/ramalingam/32/909_2.png) [@ramalingam](https://matillioncommunity.discourse.group/u/ramalingam)\
**Post date:** [June 5, 2023, 2:05pm UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/3 "2023-06-05T14:05:43Z")

</div>

[@shivamsachan303](https://matillioncommunity.discourse.group/u/shivamsachan303)​ instead of relying on a subquery, you can achieve the same thing using an inner join. You can use the Join component to achieve the same.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![shivamsachan303](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@shivamsachan303](https://matillioncommunity.discourse.group/u/shivamsachan303)\
**Post date:** [June 1, 2023, 9:29am UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/4 "2023-06-01T09:29:02Z")

</div>

Thanks for the reply, Is there any way to do it without using SQL component as to use SQL component there should be a source table but in my case I do not have source table here data is coming from matillion join component

---

<div class="post-metadata">

**Author:** ![ASD](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/asd/32/1323_2.png) [@ASD](https://matillioncommunity.discourse.group/u/ASD)\
**Post date:** [June 1, 2023, 11:35am UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/5 "2023-06-01T11:35:20Z")

</div>

You can use any component in matillion as a source table in case its connecting with your SQL query component.

You have to use $T{JOIN COMPONENT NAME} as your table name in query.

---

<div class="post-metadata">

**Author:** ![shivamsachan303](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@shivamsachan303](https://matillioncommunity.discourse.group/u/shivamsachan303)\
**Post date:** [June 1, 2023, 3:06pm UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/6 "2023-06-01T15:06:03Z")

</div>

Thanks, it worked for me.

---

<div class="post-metadata">

**Author:** ![ASD](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/asd/32/1323_2.png) [@ASD](https://matillioncommunity.discourse.group/u/ASD)\
**Post date:** [June 2, 2023, 7:10am UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/7 "2023-06-02T07:10:46Z")

</div>

Glad it helped 😀

---

<div class="post-metadata">

**Author:** ![shivamsachan303](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@shivamsachan303](https://matillioncommunity.discourse.group/u/shivamsachan303)\
**Post date:** [June 2, 2023, 10:20am UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/8 "2023-06-02T10:20:35Z")

</div>

I have one more query is there any way to perform group by operation using calculator component.

---

<div class="post-metadata">

**Author:** ![ASD](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/asd/32/1323_2.png) [@ASD](https://matillioncommunity.discourse.group/u/ASD)\
**Post date:** [June 5, 2023, 7:05am UTC](https://matillioncommunity.discourse.group/t/how-to-use-in-operator-in-matillion/2188/9 "2023-06-05T07:05:29Z")

</div>

You can perform it using aggregate component or SQL Query.
