Dumb question, but have you thought about a sum function query?
SELECT
*
FROM (
SELECT
*,
((character_1 IN ('cidd', 'tenebria')) + (character_2 IN ('cidd', 'tenebria')) + (character_3 IN ('cidd', 'tenebria')) + (character_4 IN ('cidd', 'tenebria'))) as "matches"
FROM
campingcombinations
HAVING matches > 1
) a
ORDER BY
total_morale DESC
You might need an index on all 4 of the character columns.
To the SQL purists out there: Yeah I know I can do this without having.
1
u/jj20051 Apr 12 '19
Link lol