正如您在此处看到的,TotalPic
列 return 0
。有什么问题?
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'
我试过用LEFT JOIN
这样的线程解决MYSQL COUNT return NULL?,但还是一样。
+-----------+
| images |
+-----------+
| iid |
| filename |
| extension |
| pid |
| uid |
+-----------+
+-----------+
| post |
+-----------+
| pid |
| uid |
|description|
| created_at|
+-----------+
+-----------+
| users |
+-----------+
| uid |
| fid |
| date_reg |
+-----------+