Skip to content
Advertisement

Laravel query Builder Select from subquery

I’m trying to convert a sql query to a Laravel Query builder, but i find hard understand which is the best way for FORM SUBQUERY in Laravel, because if i’m not wrong, is not something that you can normally do whit query builder, but you should implement in raw.

is this right?

and how should translate this?

I could translate just with out adding the sub query

Advertisement

Answer

I believe you can rewrite your query as correlated sub query to filter products with max value of year_production where names are duplicate

and in query builder you can transform it as

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement