SQL Help
Posted: Sun Oct 16, 2005 5:54 am
I have a comma delimited list of usernames, that I use in a query, to avoid doing a query inside of a while loop and having 50 extra queries.
It looks like this:
My problem is that no matter how I ORDER BY in the query, the date and time selected is always from the first row, not the last (as indicated by the order by id DESC).
I believe that the problem is in the GROUP BY part. I tried taking that out, and it didn't return anything.
Any help?
It looks like this:
Code: Select all
$btresult = mysql_query("SELECT username, date, time FROM blog WHERE username IN ('$friends') GROUP BY username ORDER BY id DESC");
while($btarray = mysql_fetch_assoc($btresult))
{
$thetime = $btarray['date'].' at '.$btarray['time'];
$btime[$btarray['username']] = $thetime;
}
print_r($btime);I believe that the problem is in the GROUP BY part. I tried taking that out, and it didn't return anything.
Any help?