Skip to content

Instantly share code, notes, and snippets.

@Brahyt
Last active January 8, 2020 19:14
Show Gist options
  • Select an option

  • Save Brahyt/521f57ba406bb870636a0e80ca16a47f to your computer and use it in GitHub Desktop.

Select an option

Save Brahyt/521f57ba406bb870636a0e80ca16a47f to your computer and use it in GitHub Desktop.
should be:
liked | visits | id | ...
0 0 3
4 2 2
2 2 1
getting:
liked | visits | id | ...
0 0 3
8 8 2
4 4 1
getting liked 4 visits 8
SELECT count(list_id) AS liked,
lists.id,
lists.name,
lists.tags,
lists.city,
lists.state,
lists.is_public
FROM liked_by
RIGHT JOIN lists
ON lists.id = liked_by.list_id
GROUP BY lists.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment