> For the complete documentation index, see [llms.txt](https://tobyisme.gitbook.io/laravel/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tobyisme.gitbook.io/laravel/join.md).

# Advanced Join Clauses

您還可以指定更高級的連接子句。 要開始，傳遞一個Closure作為第二個參數到join方法。 Closure將接收一個JoinClause對象，允許您指定對連接子句的約束：

```php
$this->model
     ->join($SD,function($q)use($SM,$SC,$SD){
             $q->on($SM.'.ads_id','=',$SD.'.ads_id')
             ->on($SC.'.cd_id','=',$SD.'.cd_id');
           })
```

可以on兩個條件讓你抓取到的資料更準確。
