Re: Left join help

From: Arup Rakshit <aruprakshit1987(at)outlook(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Left join help
Date: 2017-06-24 15:01:49
Message-ID: DCCAA4F7-341C-488B-9F04-986FCEE64BAB@outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Thanks everyone for taking time to explain this. I tried to add a case statement and getting errors. Can you tell me how should I add a column to mark which mission is completed and which is not. My try is not working. Instead of the new CASE expression, the query works as expected.

SELECT missions.*, CASE WHEN submissions.id IS NULL THEN 'incompleted' ELSE 'completed' END AS mission_status
FROM missions
LEFT JOIN submissions
INNER JOIN members
ON submissions.member_id = members.id AND members.id = 1
ON missions.id = submissions.mission_id
WHERE missions.track_id = 7

====

ERROR: missing FROM-clause entry for table "missions"
LINE 1: SELECT missions.*, CASE WHEN submissions.id IS NULL THEN 'in...

On Jun 24, 2017, at 4:53 AM, John W Higgins <wishdev(at)gmail(dot)com<mailto:wishdev(at)gmail(dot)com>> wrote:

SELECT *
FROM missions
LEFT JOIN submissions
INNER JOIN members
ON submissions.member_id = members.id<http://members.id/> AND members.id<http://members.id/> = 1
ON missions.id<http://missions.id/> = submissions.mission_id
WHERE missions.track_id = 7

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2017-06-24 17:00:51 Re: Left join help
Previous Message David G. Johnston 2017-06-24 03:33:44 Re: Left join help