I am trying to get all records from the product table, these records are unique but i use a leftjoin to add a second table with images of these products but when I do it will return some products more than once as some products have 1 or more images. How can I use a limit on the product_images table to make sure it will just get 1 image instead of all. The example below does not work so is this possible?
$query->select( ['a.id', 'b.image as category_image' , 'c.image as product_image'] )
->from( ['a' => 'product'] )
->leftJoin( ['b' => 'product_images'] ,'a.id = b.id AND b.type = "category" AND LIMIT = 1')
->leftJoin( ['c' => 'product_images'] ,'a.id = c.id AND b.type = "product" AND LIMIT = 1')
->all();