why this left join query failed to load all the data in left table ?
- by lzyy
users table
+-----+-----------+
| id | username |
+-----+-----------+
| 1 | tom |
| 2 | jelly |
| 3 | foo |
| 4 | bar |
+-----+-----------+
groups table
+----+---------+-----------------------------+
| id | user_id | title |
+----+---------+-----------------------------+
| 2 | 1 | title 1 |
| 4 | 1 | title 2 |
+----+---------+-----------------------------+
the query
SELECT users.username,users.id,count(groups.title) as group_count
FROM users
LEFT JOIN groups
ON users.id = groups.user_id
result
+----------+----+-------------+
| username | id | group_count |
+----------+----+-------------+
| tom | 1 | 2 |
+----------+----+-------------+
where is the rest users' info? the result is the same as inner join , shouldn't left join return all left table's data?
PS:I'm using mysql