Subqueries in CakePHP 3?
I have two tables products and product_categories that are associated through a third table, products_categories_products , according to CakePHP BelongsToMany conventions (Edit: these associations are established in ProductsTable.php and ProductCategoriesTable.php ). I want to generate a list of product categories, using the image from the best selling products to represent each category. I can achieve my desired outcome using the following function: public function findImages(Query $query, array $options) { $query->select([ 'ProductCategories.id', 'ProductCategories.name', 'ProductCategories_