我有这样的声明:
SELECT board.*, numlikes
FROM board
LEFT JOIN (SELECT
pins.board_id, COUNT(source_user_id) AS numlikes
FROM likes
INNER JOIN pins ON pins.id = likes.pin_id
GROUP BY pins.board_id) likes ON board.id = likes.board_id
WHERE who_can_tag = ''
ORDER BY numlikes DESC LIMIT 10
但我还需要将其他两个语句加入其中:
SELECT COUNT(owner_user_id)
FROM repin
INNER JOIN pins ON pins.id = repin.from_pin_id
WHERE pins.board_id = '$id'
和
SELECT COUNT(is_following_board_id)
FROM follow
WHERE is_following_board_id = '$id'
我设法让第一个加入,但我与其他人遇到了麻烦 - 认为它可能会太长。
有没有更快的执行方式?