Re: How to optimize SELECT query with multiple CASE statements?

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
Cc: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to optimize SELECT query with multiple CASE statements?
Date: 2016-10-31 15:27:37
Message-ID: CAEzk6feEgc-sbSteQOkEqq5-6gebp7P8c9Tnb6AxwU9J-zcn1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 31 October 2016 at 15:21, Geoff Winkless <pgsqladmin(at)geoff(dot)dj> wrote:
> LEFT JOIN words_social s1 ON s1.uid = in_uid
> LEFT JOIN words_social s2 ON CASE WHEN g.player1 = in_uid THEN
> g.player2 ELSE g.player1

Ugh.

Of course I meant

LEFT JOIN words_social s1 ON s1.uid = in_uid
LEFT JOIN words_social s2 ON s2.uid = CASE WHEN g.player1 = in_uid
THEN g.player2 ELSE g.player1 END

But I expect you know that...

Geoff

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2016-10-31 15:36:09 Re: initdb createuser commands
Previous Message Geoff Winkless 2016-10-31 15:21:23 Re: How to optimize SELECT query with multiple CASE statements?