# Filter element of a table from another table

**URL:** <https://discourse.cakephp.org/t/filter-element-of-a-table-from-another-table/6782>\
**Category:** Need Help\
**Created:** [October 19, 2019, 1:25am UTC](https://discourse.cakephp.org/t/filter-element-of-a-table-from-another-table/6782 "2019-10-19T01:25:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdel](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@abdel](https://discourse.cakephp.org/u/abdel)\
**Post date:** [October 19, 2019, 1:25am UTC](https://discourse.cakephp.org/t/filter-element-of-a-table-from-another-table/6782/1 "2019-10-19T01:25:44Z")

</div>

Hello,

I would like to filter rows of the table T1.

Table T1 having column A and B (numbers of records 50000)  
A(string) | B(int)  
word4 | 1254  
word4 word2 | 1542  
word1 | 47892

Table T2 having column C (numbers of records 200)  
C(string)  
word1  
word2  
word3

I would like to display all elements from T1 like this  
WORD | NUMBER  
word4 | 1254

Explication :  
row 2 of T1 is excluded because is having the word “word2” from the table T2  
row 3 of T1 is excluded because is having the word “word1” from the table T2

I tried by doing 2 loops, but the performance is so poor : 50000\*200.

Do you have another idea ?

Note : No foreign key between the 2 tables.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![coreytaylor](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coreytaylor](https://discourse.cakephp.org/u/coreytaylor)\
**Post date:** [November 2, 2019, 1:11am UTC](https://discourse.cakephp.org/t/filter-element-of-a-table-from-another-table/6782/2 "2019-11-02T01:11:28Z")

</div>

I would try something like this in postgresql:

WHERE A NOT LIKE ALL(ARRAY(SELECT C FROM T2))
