As you can see here, TotalPic column return 0. What’s the problem?
SELECT P.*, U.*, COUNT(I.iid) AS TotalPic
FROM post P
LEFT JOIN users U ON U.uid = P.uid
LEFT JOIN images I ON I.pid = P.uid
WHERE P.pid = '2'
I tried to use LEFT JOIN like this thread solution MYSQL COUNT return NULL?, but still the same.
+-----------+
| images |
+-----------+
| iid |
| filename |
| extension |
| pid |
| uid |
+-----------+
+-----------+
| post |
+-----------+
| pid |
| uid |
|description|
| created_at|
+-----------+
+-----------+
| users |
+-----------+
| uid |
| fid |
| date_reg |
+-----------+
Nevermind, thanks. I solved it by separating the query. I just need the counts and else doesn’t matter.