SELECT product.discount, product.discountType, product.salePriceLast, product.stockAmount, product_pictures.idColor, (select picture from product_pictures as pic2 where pic2.idProduct=product.id and pic2.idColor=product_pictures.idColor order by orderNumber asc limit 1) as picture1,(select picture from product_pictures as pic2 where pic2.idProduct=product.id and pic2.idColor=product_pictures.idColor order by orderNumber asc limit 1,1) as picture2, (select name from product_sets where product_sets.id=product_pictures.idColor) as colorName, product.salePriceLast, product.id, product.productCode,product.productName,product.salePrice,product.marketPrice,(select permalink from category where category.id=product.idProductCategory) as categoryName,(select brandName from brands where brands.id=product.idBrand) as brandName FROM product,product_categories,product_pictures where product_pictures.idProduct=product.id and active=1 and (product_categories.idCategory=?) and product.id=product_categories.idProduct group by product_pictures.idColor,product.id order by product.id desc LIMIT 0,16