Re: Coditional join of query using PostgreSQL

From: Nick Dro <postgresql(at)walla(dot)co(dot)il>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Coditional join of query using PostgreSQL
Date: 2017-05-15 17:52:34
Message-ID: ~0025919EAE23248FB006905@walla.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<div><div dir="rtl"><div>This is a join in a middle of query.<br><br><br></div>
<div>How can I use dynamic SQL in the middle of query?</div></div><section class="cust_msg_end"></section><blockquote style="margin:0;margin-bottom:20px;border-top:1px solid #e0e0e0;"><br>ב מאי 15, 2017 20:26, David G. Johnston כתב:<blockquote style="margin:0;margin-bottom:20px;border-top:1px solid #e0e0e0"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,sans-serif">On Mon, May 15, 2017 at 10:02 AM, Nick Dro </span><span dir="ltr" style="font-family:arial,sans-serif">&lt;<a href="mailto:postgresql(at)walla(dot)co(dot)il" target="_blank">postgresql(at)walla(dot)co(dot)il</a>&gt;</span><span style="font-family:arial,sans-serif"> wrote:</span><br></div><div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="rtl"><div dir="rtl">
<div dir="ltr">Hi, <br>I'm new to postgresql and couldn't find answer to this situation anywhere. <br>I asked this here: <br><a href="http://stackoverflow.com/questions/43984208/coditional-join-of-query-using-postgresql" rel="nofollow" target="_blank">http://stackoverflow.com/<wbr>questions/43984208/coditional-<wbr>join-of-query-using-postgresql</a><br><br>I hope there is a better solution rather than creating two separated functions :(</div>
</div></div></blockquote></div><br></div><div><div style="font-family:arial,helvetica,sans-serif">​Generate the SQL itself in a string then execute the string.&nbsp; Its called "Dynamic SQL"​.</div><div style="font-family:arial,helvetica,sans-serif"><br></div><div><font face="arial, helvetica, sans-serif"><a href="https://www.postgresql.org/docs/9.6/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN">https://www.postgresql.org/docs/9.6/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN</a></font><br></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">David J.</font></div><br></div></div>

<br></blockquote></blockquote><br></div>

Attachment Content-Type Size
unknown_filename text/html 2.0 KB

Browse pgsql-general by date

  From Date Subject
Next Message Dmitry Dolgov 2017-05-15 19:35:27 Re: Insert performance and disk usage in JSON vs JSONB
Previous Message Jack 2017-05-15 17:41:15 Re: Coditional join of query using PostgreSQL