简体   繁体   中英

Fetching single Image from Multiple Uploaded Images

I have three tables

  • Products
  • Featured Products
  • Images

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 ");

尝试使用GROUP BY a.product_id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM