Re: Select clause in JOIN statement - Mailing list pgsql-sql

From Andreas Joseph Krogh
Subject Re: Select clause in JOIN statement
Date
Msg-id OrigoEmail.41.ba27c9209458fd4c.13f4185bf48@prod2
Whole thread Raw
In response to Re: Select clause in JOIN statement  (Luca Vernini <lucazeo@gmail.com>)
List pgsql-sql
På fredag 14. juni 2013 kl. 01:10:51, skrev Luca Vernini <lucazeo@gmail.com>:
It works.
Also consider views.

Just used this on a my db:

SELECT * FROM tblcus_customer
INNER JOIN
( SELECT * FROM tblcus_customer_status WHERE status_id > 0) AS b
ON tblcus_customer.status = b.status_id
 
This query is the same as a normal JOIN:
SELECT *
FROM tblcus_customer
    INNER JOIN
    tblcus_customer_status b
        ON tblcus_customer.status = b.status_id AND b.status_id > 0
or
SELECT *
FROM tblcus_customer
    INNER JOIN
    tblcus_customer_status b
        ON tblcus_customer.status = b.status_id
WHERE b.status_id > 0
But you can JOIN on SELECTs selecting arbitrary stuff.
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

pgsql-sql by date:

Previous
From: Luca Vernini
Date:
Subject: Re: Select clause in JOIN statement
Next
From: rawi
Date:
Subject: apt.postgresql.org vs. Pitti PPA - install error