table 1
| ID | val1 |
| 1 | a |
| 2 | b |
| 3 | c |
table 2
| ID | val1 |
| 1 | a |
| 2 | b |
I need to get the table1 data, which is not on table 2
$users_without_info = DB::table('users')->rightJoin('user_infos', 'users.email', '=', 'user_infos.email')
->select('users.*')
->latest()
->get();
I tried this command, doesn’t work.
2
Answers
use inner join
if you have models then use relationships with the foreign key then in user model add relation
and the query will be
if you don’t have foreign key and want to use email as unique identifier then
Here is the solution,
Hope you will fix it..