Thanks for the feedback wilzy1 and [uk]stuff
What I have found is that if I make 2 separate queries and use a loop on the first. I can build an array that only populates the unique activity ids and then the second query pulls the information of the joined tables.
QUERY 1 Be sure to use a counter that you can use to break out of the record set return.
$listfifteen = 0;
SELECT Ach_ID, Ach_UserID FROM achievement ORDER BY Ach_Time DESC
while(($GetAchievementID = mysql_fetch_row($rsGetAchievementID)) && $listfifteen < 15)
{
if (in_array("$GetAchievementID[1]", $nextqueryarray))
{
// do nothing as this member id is already in the array
}
else
{
if ($listfifteen == 0)
{
$sqlquerylist = "t1.Ach_ID = '$GetAchievementID[0]'";
}
else
{
$sqlquerylist = $sqlquerylist . " OR t1.Ach_ID = '$GetAchievementID[0]'";
}
// add to $nextqueryarray
$nextqueryarray[$listfifteen] = $GetAchievementID[1];
$listfifteen = $listfifteen + 1;
}
}
Now that I have the array populated I can pull the second query and it will return the results in the order that I want.
SELECT t1.Ach_ID, t1.Ach_UserName, t1.Ach_TypeID, t2.AT_Type, t2.AT_Detail, t2.AT_Image, t2.AT_Detail_2, t2.AT_Detail_3, t1.Ach_Time, t1.Ach_Hash, t1.Ach_Expire FROM achievement AS t1, award_types AS t2 WHERE t1.Ach_TypeID = t2.AT_ID AND ($sqlquerylist) ORDER BY t1.Ach_Time DESC LIMIT 0 , 15
By doing this I have reduced the drag on the database and sped the query up thousands of percent.
I hope this information can be of assistance to others who face the same issues
Thanks PHP Builder for providing us a place to work together.