**My code**

```
$result=DB::table('receipts')
      ->join('dealer_m','receipts.ToDealerID','dealer_m.DealerID')
      ->join('dealer_m','receipts.FromDealerID','dealer_m.DealerID')
      ->join('product_m','receipts.ProductID','product_m.ProductID')->get();

```

**table receipts**

```
Id | FromDealerId  | ToDealerId  |  ProductId
---+---------------+-------------+------------
1         1              2            1

2         1              3            1

3         3              1            1

```

**Table dealer\_m**

```
DealerId | DealerName    
---------+-----------
  1         Dealer One
  2         Dealer Two
  3         Dealer Three

```

**Table product\_m**

```
ProductId | ProductName
----------+-----------
    1       Product One
    2       Product Two

```

**Expected Output**

```
Id | FromDealerId  | ToDealerId  |  ProductId | FromDealerName | ToDealerName | ProductName
---+---------------+-------------+------------+----------------+--------------+------------

 1         1              2            1         Dealer One      Dealer Two  Product One

 2         1              3            1         Dealer One      Dealer Three  Product One

 3         3              1            1         Dealer Three    Dealer One   Product One

```

When I run my code it gets an error 

> 
> SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique
>  table/alias: 'dealer\_m' (SQL: select '' from 'receipts' inner join
>  'dealer\_m' on 'receipts'.'ToDealerID' = `dealer\_m'.'DealerID' inner
>  join 'dealer\_m' on 'receipts'.'FromDealerID' = 'dealer\_m'.'DealerID'
>  inner join 'product\_m' on 'receipts'.'ProductID' =
>  'product\_m'.'ProductID')
> 
> 
> 

How to solve this ???

Thank You