I am using Laravel 5.5 .
I have a database containing users. The problem is that some users exist more than once due to an error. I want to query my database and select all the "unique" users.
Using the word "unique" , I mean the following:
If the email user exists 50 times, I need the line that is closest to . "test@test.com"
created_at
now
My query, which returns all users, is written below:
DB::table('users')
->select('name', 'surname', 'email', 'phone', 'answers', 'newsletter', 'created_at')
->get();
I'm confused and I'm not sure what I should use limit
, combining it with the order in the column created_at
.
Any ideas?
source
share