Musadiq Khan
Musadiq Khan

Reputation: 28

Fetching single Image from Multiple Uploaded Images

I have three tables

Each Product has multiple images but for homepage I want to display only one image for featured products.

This is the query I wrote but for products with 2 images it displays same product twice with different image. Any help?

mysqli_query($conn, "SELECT * FROM products a , featured_product b, image c WHERE b.p_id = a.product_id AND a.product_id = c.product_id ");

Upvotes: 0

Views: 32

Answers (1)

JustBaron
JustBaron

Reputation: 2347

try using GROUP BY a.product_id

Upvotes: 1

Related Questions