I have a query like, below which gives the following results. For one given pcid there may be one or more images. I only want to grab the first record if the pcid has more than 1 images returned. I know distinct will not work in this case. Any ideas will be appreciated. thanks
select p.pcid,p.pc_name,p.pc_image_name
from pc p LEFT JOIN pc_goods pcm on p.pcid = pcm.pcid AND pcm.media_type = 'I'
AND pcm.act_ind = 'Y' AND pcm.fea_ind = 'Y' INNER JOIN pc_cat pcat
ON p.category_id = pcat.cat_id
and p.fea_ind = 'Y' AND p.act_ind = 'Y'
order by pcid
Current results
pcid pc_name pc_image_name
--------------------------------
1120 testone one.jpg
1120 testwo two.jpg
1121 testthree three.png
1125 testfour four.png
1128 test5 five.jpg
1128 test6 six.jpg
Desired results,
pcid pc_name pc_image_name
--------------------------------
1120 testone one.jpg
1121 testthree three.png
1125 testfour four.png
1128 test5 five.jpg