Created
September 19, 2022 21:27
-
-
Save JorgeMichelena/c1487d9c4b3a72256cadbbf00df11781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT "targets_target"."id", "targets_target"."user_id", | |
... | |
"targets_target"."created_at", "targets_target"."updated_at", | |
CASE WHEN ("targets_match"."id" IS NOT NULL OR T3."id" IS NOT NULL) | |
THEN true | |
ELSE false END AS "has_matches" | |
FROM "targets_target" | |
LEFT OUTER JOIN "targets_match" ON ("targets_target"."id" = "targets_match"."target_1_id") | |
LEFT OUTER JOIN "targets_match" T3 ON ("targets_target"."id" = T3."target_2_id") | |
ORDER BY "has_matches" DESC | |
SELECT "targets_match"."id", "targets_match"."target_1_id", | |
"targets_match"."target_2_id", "targets_match"."created_at" | |
FROM "targets_match" | |
WHERE "targets_match"."target_1_id" IN (6, 28, 30, 32, 34, 36, 38, 40, 2, 4, 26, 8, 10, 12, 14, 25, 33, 29, 35, 27, 39, 31, 37, 1, 18, 13, 17, 5, 15, 21, 24, 19, 23, 3, 7, 20, 16, 11, 9, 22) | |
SELECT "targets_match"."id", "targets_match"."target_1_id", | |
"targets_match"."target_2_id", "targets_match"."created_at" | |
FROM "targets_match" | |
WHERE "targets_match"."target_2_id" IN (6, 28, 30, 32, 34, 36, 38, 40, 2, 4, 26, 8, 10, 12, 14, 25, 33, 29, 35, 27, 39, 31, 37, 1, 18, 13, 17, 5, 15, 21, 24, 19, 23, 3, 7, 20, 16, 11, 9, 22) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment