Skip to content

How to add relations to a View collection. #2029

Closed Answered by ganigeorgiev
Xyphyn asked this question in Q&A
Discussion options

You must be logged in to vote

You can add the column communities.id as community but in order to be detected as relation it needs to be from "non-primary" table (I'll consider updating the rules and allow any aliased id column to be detected as relation).

As a workaround, for now you can try specifying a dummy primary table:

SELECT
    communities.id,
    communities.id as community,
    count(DISTINCT posts.id) as posts,
    count(DISTINCT users.id) as members
FROM (select 1) as dummy, communities
LEFT JOIN users on users.communities LIKE '%' || communities.id || '%'
LEFT JOIN posts on posts.community = communities.id
GROUP BY communities.id

Replies: 6 comments 13 replies

Comment options

You must be logged in to vote
6 replies
@pyronaur
Comment options

@ganigeorgiev
Comment options

@pyronaur
Comment options

@ganigeorgiev
Comment options

@pyronaur
Comment options

Answer selected by Xyphyn
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@ganigeorgiev
Comment options

@ganigeorgiev
Comment options

@ganigeorgiev
Comment options

@M4rk3tt0
Comment options

Comment options

You must be logged in to vote
2 replies
@ganigeorgiev
Comment options

@ganigeorgiev
Comment options

Comment options

You must be logged in to vote
0 replies

This comment was marked as off-topic.

@ganigeorgiev

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants