我有查询
SELECT P.*, COUNT(L.to) AS likes, U.name AS ownerName, U.username AS ownerUsername,
U.picture AS ownerPicture
FROM sn_posts P LEFT JOIN sn_users AS U
ON U.id = P.ownerID
LEFT JOIN sn_likes AS L
ON L.to = P.id
WHERE (P.ownerID = 69)
GROUP BY P.id
ORDER BY P.id DESC
它正在服用 - 0.3337秒,
答案 0 :(得分:0)
为表sn_posts
添加ownerID
字段的索引
更好