This question already has answers here:
MYSQL Select MAX Date inside a join statement (2 answers)
SELECT query return 1 row from each group (3 answers)
Closed 2 months ago.
I want to get product thumbnails on a product category page, each product 1st thumbnail image needs to be shown. right now the last image is showing. here is the screen shot for my db structure
EDIT:
right now the table format as screenshot, there are 4 images with order 1,2,3,4 i want to get the image with img_order 1.
when i am running sql query
SELECT i.img_order,p.*, i.product_id, i.dirName, i.img FROM products p inner JOIN product_images i ON i.product_id = p.id WHERE p.status = 1 and i.product_id=329 AND i.type = 'Static' GROUP BY i.product_id ORDER BY i.img_order asc
it's giving wrong result see screenshot
but i want to get the image with img_order 1.
3条答案
按热度按时间soat7uwm1#
尝试类似这样的操作:
小提琴来了
gstyhher2#
我用下面的sql查询找到了解决方案:
0wi1tuuw3#
你有没有试过这样的东西。
选中所有行