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 Quote Link to comment Share on other sites More sharing options...
fenway Posted November 11, 2011 Share Posted November 11, 2011 I don't believe you. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.