I have a view where it has a multiple-select list option for the user. I wanted to select the department in my select list but I have a problem here where I join the `departments` from `users` but I wanted to show only once the `department_name` in my select list. 

I have a one to many relationship. **`departments`** and **`users`**

[![SC](https://i.stack.imgur.com/MhLqX.jpg)](https://i.stack.imgur.com/MhLqX.jpg)

**Join statement**

```
$resultRecipient = DB::table('users')->select('users.username', 'departments.department_name', 'users.id')
    ->join('departments', 'departments.id', '=', 'users.department_id')->get();

```

**View**

```
@foreach ($resultRecipient as $list)
    <option value = "{{ $list->id }}">{{ $list->username }}</option>
    <option value = "{{ $list->id }}">{{ $list->department_name }}</option>
@endforeach

```

[![SC1](https://i.stack.imgur.com/Z1akB.jpg)](https://i.stack.imgur.com/Z1akB.jpg)

How can avoid the repeating values of `department_name` in my select? Any help or tips will appreciated!

**UPDATE**

Lets say I have users named A, B and C belongs to Department of IT and users named D, E belongs to Department of Engr. What I wanted to show in my view is all the users and all the departments. So the values of select list will be.

A

B

C

D

E

Department of IT

Department of Engr