[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pgsql-bugs
Subject:    Re: Query will execute when inner query have issue
From:       "David G. Johnston" <david.g.johnston () gmail ! com>
Date:       2020-01-23 18:50:46
Message-ID: CAKFQuwZx=0T+P_kGJ38mCFHUwmkO8Mi4ow6ADZ5hMnsOkAFQaw () mail ! gmail ! com
[Download RAW message or body]

On Thu, Jan 23, 2020 at 9:19 AM selva kumar <selva.logic@hotmail.com> wrote:

> But the following query will executed
>
> select * from product where productid in (select productid from sales
> where salesdate='2020-01-22')
>
>
>
Which isn't the same as what you first posted because of the absence of
table qualifications.  That single difference, explained by Tom, completely
explains why the original post did in fact provoke and error and this query
does not.

The take-away is make sure to test your queries; and when dealing with
sub-queries its usually a good idea of add a table qualification to your
fields.

David J.

[Attachment #3 (text/html)]

<div dir="ltr"><div dir="ltr"><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><span \
style="font-family:Arial,Helvetica,sans-serif">On Thu, Jan 23, 2020 at 9:19 AM selva \
kumar &lt;<a href="mailto:selva.logic@hotmail.com">selva.logic@hotmail.com</a>&gt; \
wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_5911950095974310732WordSection1">
<p class="MsoNormal">But the following query will executed<br></p><p \
class="MsoNormal"><u></u></p> <p class="MsoNormal">select * from product where \
productid in (select productid from sales where \
salesdate=&#39;2020-01-22&#39;)<u></u><u></u></p> <p \
class="MsoNormal"><br></p></div></div></blockquote><div><br></div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif">Which isn&#39;t \
the same as what you first posted because of the absence of table qualifications.   \
That single difference, explained by Tom, completely explains why the original post \
did in fact provoke and error and this query does not.</div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif">The take-away is \
make sure to test your queries; and when dealing with sub-queries its usually a good \
idea of add a table qualification to your fields.</div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif">David J.</div><div \
class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><br></div></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic