Re: Subselect with no records results in final empty set - Mailing list pgsql-general

From David Johnston
Subject Re: Subselect with no records results in final empty set
Date
Msg-id CAKFQuwbVWgCCBwNsCGsYJvhWyEJbRmHxz9-e+OLbUEMuEC=vNQ@mail.gmail.com
Whole thread Raw
In response to Re: Subselect with no records results in final empty set  ("Sterpu Victor" <victor@caido.ro>)
List pgsql-general
On Thu, Jan 29, 2015 at 1:22 PM, Sterpu Victor <victor@caido.ro> wrote:
It works as you sugested, this is the syntax I used:
SELECT * FROM
(SELECT 1 AS t1, 2 AS t2) AS t1
LEFT JOIN (SELECT * FROM atc WHERE id = '1231222') AS t2 ON (null)

Thank you.


You will notice that everyone responding to you is bottom-posting...
 
​Anyway, the use of "ON (null)" is unusual...

Also, the fact that your toy model is making considerable use of "CROSS JOIN" is unusual; one common reality of "relational databases" is that usually the things you are going together are "related" and the join conditions reflect those relationships.  I'd suggest using actual tables (or CTE/WITH) with multiple rows of data to try and learn how to write queries.  The number of times you are going to join together multiple results each only having a single row is slim.

David J.​


pgsql-general by date:

Previous
From: "Sterpu Victor"
Date:
Subject: Re: Subselect with no records results in final empty set
Next
From: John R Pierce
Date:
Subject: Re: Subselect with no records results in final empty set