Reputation: 1447
My MySQL query is displaying just one row (instead of all of the rows), but when I do a COUNT on the query, it shows the correct number of rows in the query. What seems to be the problem here?
$sql5 = "SELECT m.*, i.*, COUNT(*) AS num, m.id AS m_id FROM members m JOIN roommate_seek i ON m.id = i.member_id
WHERE _school = :school AND i.category = :category";
foreach ($db->query($sql5, array('school' => $_GET['school'], 'category' => $category)) AS $result3)
{
echo "{$result3['m_id']}";
}
Upvotes: 0
Views: 41
Reputation: 7590
You are using an aggregate function (COUNT
) without GROUP BY
. In that case it is suppose to return exactly one row.
Upvotes: 4