Answer the question
In order to leave comments, you need to log in
Is there a possibility in Laravel using querybuilder to make queries with subqueries?
Compiled such a query, tested in phpmyadmin
SELECT from_id, MAX(id) as updated
FROM (SELECT from_id, id
FROM messages
WHERE to_id = 1
UNION SELECT to_id, id
FROM messages
WHERE from_id = 1
ORDER BY id DESC) as talks
GROUP BY from_id
ORDER BY updated DESC
now it needs to be rewritten via querybuilder
But I didn't find anything similar in the documentation
Answer the question
In order to leave comments, you need to log in
description and text are reserved in the muscle.
if you want to use them as column names, then use the backtic: `description` and `text` . Well, this is a kagbe generally accepted rule for avoiding mistakes.
crap, using DB::raw inside select
https://laracasts.com/discuss/channels/eloquent/se...
itsolutionstuff.com/post/laravel-5-join-with-subqu...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question