php - data duplicates after adding new fields with the same product_id -


i have 2 tables 1 called products other product_images. product_images has 6 fields in layout.

product_id, small_image, medium_image, large_image, width, height 

small_image, medium_image , large_image null fields.

my data has duplicated after adding fields small_image , large_image have same product_id.

my sql statement

"select *,           i.medium_image, i.width, i.height,      coalesce((select count(*)      order_details od      od.product_id = p.product_id), 0) most_popular  products p  inner join product_images on i.product_id = p.product_id p.department_id=:department_id , p.is_active=1 $orderby         limit :limit offset :offset"); 

what need change sql statement select medium_image product won't duplicate, tried using distinct that's not working. want return single product_image row medium_image related product_id

try adding

group product_id 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -