Answer the question
In order to leave comments, you need to log in
Why does it show 2 identical entries?
Displays three entries, but two are the same
SELECT
:projection,
"user".firstname || ' ' || "user".lastname AS created_by,
"campaign_status".name as status
FROM campaign
LEFT JOIN :user "user" ON campaign.user_id="user".id
LEFT JOIN :campaign_status "campaign_status" ON campaign.campaign_status_id="campaign_status".id
LEFT JOIN user_group "user_group" ON "user".id = "user_group".user_id
WHERE
"user_group".group_id = $groupId
AND (campaign.search @> '{"tags_in": [$tagId]}' AND not(campaign.search @> '{"contacts_out": [$contactId]}'))
OR (campaign.search @> '{"contacts_in": [$contactId]}')
GROUP BY campaign.id, "user".id, "campaign_status".id
ORDER BY :sortBy :orderBy
LIMIT $limit OFFSET ($page - 1) * $limit
Answer the question
In order to leave comments, you need to log in
I just passed a collection with tags and imploded it, then checked with IN().
As a result, the request turned out like this IN ('[10]','[20] и т.д.)
and completely satisfied my task
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question