I have those 3 tables enter image description here and i don't know how to connect them to have a users.id, username, number of likes and number of comments by each user. I want to have it in 4 columns.
I tried this: select u.id, u.username, count(l.photo_id) as posts_liked from users u left join likes l on u.id = l.user_id group by u.id UNION ALL select u.id, u.username, count(c.user_id) as com_written from users u left join comments c on u.id = c.user_id group by u.id; but the result is just 3 tables with number of comments in a column with number of likes.