Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UnOFo-0007kt-D4 for pgsql-sql@arkaria.postgresql.org; Fri, 14 Jun 2013 07:17:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UnOFn-0004jj-Pz for pgsql-sql@arkaria.postgresql.org; Fri, 14 Jun 2013 07:16:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UnOFm-0004iO-0D for pgsql-sql@postgresql.org; Fri, 14 Jun 2013 07:16:58 +0000 Received: from prod2.officenet.no ([195.159.87.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UnOFe-0003b7-NC for pgsql-sql@postgresql.org; Fri, 14 Jun 2013 07:16:57 +0000 Received: from localhost ([127.0.0.1] helo=prod2) by prod2.officenet.no with esmtp (Exim 4.76) (envelope-from ) id 1UnODb-0007Mh-On for pgsql-sql@postgresql.org; Fri, 14 Jun 2013 09:14:43 +0200 Date: Fri, 14 Jun 2013 09:14:43 +0200 (CEST) From: Andreas Joseph Krogh To: pgsql-sql@postgresql.org Message-ID: In-Reply-To: Subject: Re: Select clause in JOIN statement MIME-Version: 1.0 X-Mailer: OfficeNet Mail 1.9.0-SNAPSHOT X-Pg-Spam-Score: 0.3 (/) Content-Type: text/html;charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org
P=C3=A5 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 =3D b.status_id
=C2=A0
This query is the same as a normal JOIN:
SELECT *
FROM =
tblcus_customer
    INNER JOIN
    tblcus_customer_status b
        ON tblcus_customer.status =3D b.status_id AND b.status=
_id > 0
or
SELECT *
FROM =
tblcus_customer
    INNER JOIN
    tblcus_customer_status b
        ON tblcus_customer.status =3D b.status_id
WHERE b.status_id > 0<=
/font>
But you can JOIN on SELECTs selecting arbitrary stuff.
=C2=A0
--
Andreas Joseph Krogh <andreak@officenet.no>=C2=A0 =C2=A0 =C2=A0 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
=C2=A0
=