I'm trying to understand how to create queries with subqueries in Query Builder. The problem is that the official documentation is extremely brief and not very explanatory in some specific points. In particular, the methods joinSub()
and raw()
are not particularly detailed, and everything I find in blogs and other sites are mere copies (original or translated) of the document, but do not provide additional explanations.
I have this query in SQL:
SELECT * FROM articles AS tabla, (SELECT MIN(created_at) AS minimo
FROM articles) AS sub WHERE tabla.created_at = sub.minimo
As you can see, it's about recovering the records with the oldest creation date. I know there are other easier ways to do this, but the query was created to explore the subqueries with Query Builder and with Eloquent.
I would appreciate it if you did not tell me how the sample query that I have put should be, if not tell me where to find more detailed information on these two methods in particular, because what I need is to understand the operation.