Re: Displaying chat by punished users only to themselves (db fiddle attached)

Поиск
Список
Период
Сортировка
От Alexander Farber
Тема Re: Displaying chat by punished users only to themselves (db fiddle attached)
Дата
Msg-id CAADeyWiL239tEuwGuc0Garj_w9r2zYrzr=-uDou=K_jYDFWbsA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Displaying chat by punished users only to themselves (db fiddle attached)  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Displaying chat by punished users only to themselves (db fiddle attached)
Список pgsql-general
I have tried CROSS JOIN and CASE WHEN (why be greedy, right?):

        WITH myself AS (
            SELECT uid 
            FROM words_social
            WHERE social = in_social
            AND sid = in_sid
            LIMIT 1
        ),
        opponent AS (
             SELECT CASE WHEN player1 = myself.uid THEN player2 ELSE player1 END
             FROM words_games
             WHERE gid = in_gid
        )
        SELECT
                CASE WHEN c.uid = myself.uid THEN 1 ELSE 0 END,
                c.msg
        FROM  myself CROSS JOIN opponent
        WHERE   (c.uid = myself.uid OR NOT opponent.muted)
        ORDER BY c.CREATED ASC;

but the error is:

ERROR:  missing FROM-clause entry for table "myself"
LINE 60:              SELECT CASE WHEN player1 = myself.uid THEN play...
                                                 ^

В списке pgsql-general по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Displaying chat by punished users only to themselves (db fiddle attached)
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Displaying chat by punished users only to themselves (db fiddle attached)