Answer the question
In order to leave comments, you need to log in
SELECT DISTINCT, ORDER BY expressions must appear in select?
User::select( DB::raw('DISTINCT(user.id) as user_id'), 'users.role_id')
// ->distinct()
->join('roles', 'users.role_id', '=', 'roles.id')
// ->sharedLock()
->inRandomOrder()
->orderByDesc('user_id')
->limit($limit)
->get();
Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list↵LINE 1: ...10
Syntax error: 7 ERROR: syntax error at or near ","↵LINE 1: select DISTINCT ON(users.id),
...
->inRandomOrder()
...
..."users"."deleted_at" is null order by RANDOM() 1...
Answer the question
In order to leave comments, you need to log in
does not work because there is only a function definition, not a call ... then either call the function, or declare this function as "automatically started"
(function getBiggerBook(book) {
.....
})(Book)
PostgreSQL does not support random() + distinct() sampling by standard means, see below for information and possible solutions.
https://github.com/laravel/framework/issues/20457
https://www.postgresql.org/message-id/5070.1286027...
https://stackoverflow.com/questions/28371105/selec...
https ://stackoverflow.com/questions/11401229/how-t...
https://stackoverflow.com/questions/8446839/select...
https://stackoverflow.com/questions/24823915/how-t.. https :
//stackoverflow.com/questions/34870957/subqu...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question