elabuwa Posted November 11, 2011 Share Posted November 11, 2011 Hi guys, DB is mysql. I have the below query i'm trying to run through PHP. $sql = "SELECT DISTINCT pid FROM campaign_details WHERE camp_id='$camp_id' LIMIT 7"; $newquery = mysql_query($sql) or die(mysql_error()); There are 10 ditinct PID values but I want only 7. The stupid thing returns all of them when I need to limit them at 7. Any work around this? Or Do I need to go and take a coffee break and have another look? haha. Cheers Link to comment https://forums.phpfreaks.com/topic/250912-distinct-limit-not-working/ Share on other sites More sharing options...
fenway Posted November 11, 2011 Share Posted November 11, 2011 I don't believe you. Link to comment https://forums.phpfreaks.com/topic/250912-distinct-limit-not-working/#findComment-1287343 Share on other sites More sharing options...
The Little Guy Posted November 11, 2011 Share Posted November 11, 2011 Try this: SELECT pid FROM campaign_details WHERE camp_id='$camp_id' GROUP BY pid LIMIT 7 Link to comment https://forums.phpfreaks.com/topic/250912-distinct-limit-not-working/#findComment-1287367 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.