Есть 3 таблицы: notes, users и comments. Связи:
notes.author_id - users.id
comment.note_id - notes.id
При выборке заметок из notes нужно получить имя автора из users (c этим разобрался) И подсчитать количество комментариев к заметке. Как это сделать?
SELECT notes.id, notes.title, notes.content, users.username -- COUNT(comments.id) AS comments_count FROM notes INNER JOIN users ON (notes.author_id=users.id) --??? ORDER BY datetime DESC