From: | Arup Rakshit <aruprakshit1987(at)outlook(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Left join help |
Date: | 2017-06-23 21:25:46 |
Message-ID: | 097542ED-F8A8-4560-9B01-D718D4BC637E@outlook.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I have this relationship Track has many missions. Missions has many submissions. Each Submission has one member and one mission. Say I have track id 7. I want to find out which missions under track 7 are submitted by John ( a user id say 3 ) and which are not yet. I tried a query, but it is not giving me any result. Can anyone help me pls?
SELECT missions.*,
CASE WHEN submissions.id IS NULL THEN 'incompleted'
ELSE 'completed' END AS mission_status
FROM "missions" LEFT JOIN submissions ON submissions.mission_id = missions.id
INNER JOIN members ON members.id = submissions.member_id
WHERE (members.id = 1 AND missions.track_id = 7)
The above query really not showing any output. Any help to solve this?
Tables are posted here: http://dpaste.com/1EXF4KQ
Thanks,
A
From | Date | Subject | |
---|---|---|---|
Next Message | Jon Erdman | 2017-06-23 21:39:20 | Re: Chained slaves smaller? |
Previous Message | Jerry Sievers | 2017-06-23 20:37:22 | Re: Chained slaves smaller? |