Here is my total user without JOIN statement.
mysql> SELECT COUNT(*) AS total
-> FROM users;
+--------+
| total |
+--------+
| 608000 |
+--------+
1 row in set (0.28 sec)
And with LEFT OUTER JOIN
mysql> SELECT COUNT(*) AS total
-> FROM users
-> LEFT OUTER JOIN users_icon
-> ON users.uid = users_icon.iconuid
-> LEFT OUTER JOIN icon_code
-> ON users_icon.icondata = icon_code.iconid;
+--------+
| total |
+--------+
| 608084 |
+--------+
1 row in set (3.78 sec)
Here I’ve got different total number. With the LEFT OUTER JOIN how do I get the total number is 608000?
Use:
count(distinct users.id)to get correct count.