简体   繁体   中英

How to run left outer join SQL query in laravel

I am unable to write this query in laravel using query builder:

```
SELECT pt.name, IF(up.permission_id IS NULL,'false','true') permission
    FROM mercuri_permission_type pt 
    LEFT OUTER JOIN mercuri_user_permission up 
    ON pt.id = up.permission_id AND up.user_id = $user_id
```

You should do multi left join to handle this; But I suggest you use doctrine ORM and run this query on doctrine. In order to use Doctrine in Laravel the links below would be useful:

Getting started doctrine 2 laravel

Working entities doctrine 2

Creating testing doctrine repositories

Using doctrine query language

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM