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
<div>På fredag 14. juni 2013 kl. 01:10:51, skrev Luca Vernini <<a href="mailto:lucazeo@gmail.com"
target="_blank">lucazeo@gmail.com</a>>:</div><blockquotestyle="border-left: 1px solid rgb(204, 204, 204); margin:
0pt0pt 0pt 0.8ex; padding-left: 1ex;"><div style="display:inline; font-family: monospace; font-size: 12px;">It
works.<br/> Also consider views.<br /><br /> Just used this on a my db:<br /><br /> SELECT * FROM tblcus_customer<br />
INNERJOIN<br /> ( SELECT * FROM tblcus_customer_status WHERE status_id > 0) AS b<br /> ON tblcus_customer.status =
b.status_id</div></blockquote><div> </div><div>Thisquery is the same as a normal JOIN:</div><div><style
type="text/css"></style><preclass="western" style="background: #ffffff; border: none; padding: 0in"> 
<font color="#000080"><font face="DejaVu Sans Mono"><b>SELECT</b> </font></font><font color="#000000"><font
face="DejaVuSans Mono">*</font></font> 
<font face="DejaVu Sans Mono"><font color="#000080"><b>FROM </b></font><font
color="#000000">tblcus_customer</font></font>
<font color="#000000">    </font><font color="#000080"><font face="DejaVu Sans Mono"><b>INNER JOIN</b></font></font>
<font color="#000080">    </font><font color="#000000"><font face="DejaVu Sans Mono">tblcus_customer_status
b</font></font>
<font color="#000000">        </font><font color="#000080"><font face="DejaVu Sans Mono"><b>ON </b></font></font><font
color="#000000"><fontface="DejaVu Sans Mono">tblcus_customer.status = b.status_id </font></font><font
color="#000080"><fontface="DejaVu Sans Mono"><b>AND </b></font></font><font color="#000000"><font face="DejaVu Sans
Mono">b.status_id> </font></font><font color="#0000ff"><font face="DejaVu Sans Mono">0</font></font> 
</pre> or</div><div><style type="text/css"></style><pre class="western" style="background: #ffffff; border: none;
padding:0in"> 
<font color="#000080"><font face="DejaVu Sans Mono"><b>SELECT</b></font> </font><font color="#000000"><font
face="DejaVuSans Mono">*</font></font> 
<font face="DejaVu Sans Mono"><font color="#000080"><b>FROM </b></font><font
color="#000000">tblcus_customer</font></font>
<font color="#000000">    </font><font color="#000080"><font face="DejaVu Sans Mono"><b>INNER JOIN</b></font></font>
<font color="#000080">    </font><font color="#000000"><font face="DejaVu Sans Mono">tblcus_customer_status
b</font></font>
<font color="#000000">        </font><font color="#000080"><font face="DejaVu Sans Mono"><b>ON </b></font></font><font
color="#000000"><fontface="DejaVu Sans Mono">tblcus_customer.status = b.status_id</font></font> 
<font face="DejaVu Sans Mono"><font color="#000080"><b>WHERE </b></font><font color="#000000">b.status_id >
</font><fontcolor="#0000ff">0</font></font></pre> But you can JOIN on SELECTs selecting arbitrary
stuff.</div><div> </div><divclass="origo-email-signature">--<br /> Andreas Joseph Krogh <andreak@officenet.no>   
 mob: +47 909 56 963<br /> Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no<br /> Public key:
http://home.officenet.no/~andreak/public_key.asc</div><div> </div>

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