jonniejoejonson Posted March 28, 2011 Share Posted March 28, 2011 I am trying to get the select the mediaId with the smallest mediaOrder.. SELECT mediaId, MIN(mediaOrder) FROM cms_media_on_pages AS mop WHERE userId='3' GROUP BY pageIdI am trying to get the select the mediaId with the smallest mediaOrder.. SELECT mediaId, MIN(mediaOrder) FROM cms_media_on_pages AS mop WHERE userId='3' GROUP BY pageId This selects the min mediaOrder but not the mediaId with the smallest mediaOrder?... I would have thought this to work but it doesnt... SELECT mediaId FROM cms_media_on_pages AS mop WHERE userId='3' AND MIN(mediaOrder) GROUP BY pageId This selects the min mediaOrder but not the mediaId with the smallest mediaOrder?... I would have thought this to work but it doesnt... SELECT mediaId FROM cms_media_on_pages AS mop WHERE userId='3' AND MIN(mediaOrder) GROUP BY pageId Link to comment https://forums.phpfreaks.com/topic/231937-min/ Share on other sites More sharing options...
Pikachu2000 Posted March 28, 2011 Share Posted March 28, 2011 What are the data types of the fields? What would be a representative sample of the data you're having problems with? Link to comment https://forums.phpfreaks.com/topic/231937-min/#findComment-1193486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.