Id Cat_Id P_Name Image_Path 1040 1010 aaaaaaa /images/products/NewImages/Gamo-Whisper- 1040 1010 aaaaaaa /images/products/NewImages/IMG_0401.png 1040 1010 aaaaaaa /images/products/NewImages/IMG_0402.png 1040 1010 aaaaaaa /images/products/NewImages/gamo-silent- 1040 1010 aaaaaaa /images/products/NewImages/SMALL_IMG_0135a.jpg 1041 1010 bbbbbbbbbbb /images/products/NewImages/SMALL_IMG_0135a.jpg 1041 1010 bbbbbbbbbbb /images/products/NewImages/SMALL_IMG_0140a.jpg 1041 1010 bbbbbbbbbbb /images/products/NewImages/SMALL_IMG_0135a.jpg 1041 1010 bbbbbbbbbbb /images/products/NewImages/SMALL_IMG_0140a.jpg 1042 1011 ccccccccccc /images/products/NewImages/IMG_0413.png
Id P_Id ImagePath 1041 1040 /images/products/NewImages/IMG_0401.png 1042 1040 /images/products/NewImages/IMG_0402.png 1043 1040 /images/products/NewImages/detail_whisper_g2.jpg 1044 1040 /images/products/NewImages/gamo-silent-stalker-whisper-igt-22-cal-air- 1045 1041 /images/products/NewImages/SMALL_IMG_0135a.jpg 1046 1041 /images/products/NewImages/SMALL_IMG_0140a.jpg 1047 1041 /images/products/NewImages/SMALL_IMG_0135a.jpg 1048 1041 /images/products/NewImages/SMALL_IMG_0140a.jpg 1049 1040 /images/products/NewImages/Gamo-Whisper-CFR-Fixed-Barrel_GA- 1050 1042 /images/products/NewImages/IMG_0413.png
Id P_Name Cat_Id 1040 aaaaaaaaaa 1010 1041 aaaaaaaaaa 1010 1042 aaaaaaaaaa 1010 1043 aaaaaaaaaa 1010 1044 aaaaaaaaaa 1010 1045 bbbbbbbbbb 1010 1046 bbbbbbbbbb 1010 1047 cccccccccc 1011 1048 cccccccccc 1011 1049 cccccccccc 1011
SELECT A.Id, A.P_Name, B.ImagePath FROM Product A INNER JOIN (SELECT P_Id,MIN(ImagePath) ImagePath FROM img GROUP BY P_Id) AS B ON B.P_Id = A.ID
SELECT t1.P_ID, P.CAT_ID, P.P_NAME, IPT.IMAGEPATH FROM (SELECT P_ID, MAX(ID) AS MAX_ID FROM ImagePathTable GROUP BY P_ID ) T1 INNER JOIN ImagePathTable IPT on T1.MAX_ID = IPT.ID INNER JOIN PRODUCT P ON T1.P_ID = P.ID
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)