# Associate to self

**URL:** <https://discourse.cakephp.org/t/associate-to-self/5013>\
**Category:** Need Help\
**Created:** [September 27, 2018, 12:49pm UTC](https://discourse.cakephp.org/t/associate-to-self/5013 "2018-09-27T12:49:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![elbert](https://avatars.discourse-cdn.com/v4/letter/e/35a633/32.png) [@elbert](https://discourse.cakephp.org/u/elbert)\
**Post date:** [September 27, 2018, 12:49pm UTC](https://discourse.cakephp.org/t/associate-to-self/5013/1 "2018-09-27T12:49:20Z")

</div>

Hi Everyone,  
Quick question: Is it possible to have (a sort of) belongsToMany association to itself?

I would like to be able to ‘attach’ products to eachother. In the same way as I would ‘attach’ a product to a category.  
In a category-situation, I would have a categories\_products table and do this:

> ```
> $this->belongsToMany('Categories', [
> 'foreignKey' => 'product_id',
> 'targetForeignKey' => 'category_id',
> 'joinTable' => 'categories_products'
> ]);
> 
> ```

But how do I achieve this when I want to have a collection of related products? Or is that not possible at all? (not with associations?). Can someone point me in the right direction? Thanks!

Kind regards,  
Elbert
