My table is 'gallery_list' and columns are ID, sessionid, emailedto, and date.
$query = mysql_query("SELECT DISTINCT sessionid, emailedto, date FROM gallery_list ORDER BY date DESC") or die(mysql_error());
echo "
while($row = mysql_fetch_assoc($query)){
echo "
";echo "
VIEW GALLERY SELECTION";echo "
".$row['emailedto']."";echo "
".$row['date']."";echo "
".$record_count."";echo "
";}
echo "
";This query works just fine, but how can I echo the quantity of records that contain the same sessionid? For example 4 records may contain the same sessionid, I just want to display the number 4.
解决方案
So your query would be
SELECT session_id, COUNT(*)
FROM gallery_list
GROUP BY session_id