Re: Aliased table names ...oddity?

From: Steve Tucknott <steve(at)retsol(dot)co(dot)uk>
To: PostGreSQL <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Aliased table names ...oddity?
Date: 2005-06-30 07:34:03
Message-ID: 1120116843.1195.36.camel@retsol1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Ignore this.
Just seen the post re MySQL/PostgreSQL 'gotchas' - and this is one of
them - with the answer that I was after.

On Thu, 2005-06-30 at 07:54, Steve Tucknott wrote:
> PostgreSQL-7.4.5
>
> I don't know whether this is a 'bug' (it seems like designed behaviour)
> - but if you do:
> SELECT markUp.*
> FROM markUp AS mark
> JOIN clientBranch AS clntB
> ON mark.foreignRecNo = clntB.clientRecNo
> AND clntB.recNo = 2
> WHERE mark.serviceCoBranchRecNo = 2
> AND mark.foreignTableName = 'client'
>
>
> So the table has an ALIAS that is ignored in the SELECT clause, then the
> WHERE clause is 'ignored' and all rows from the table are returned.
> Obviously its a typo in the original SQL - (but one that's very
> difficult to pick up unless the data returned is obviously outside
> limits). Running the SQL in PSQL, it seems that a FROM clause is
> automatically appended for the missing 'markUp' table - so it does seem
> that this is intentional. Is there a way to have this 'rejected' as an
> error - ie selecting from a table not included in the query?
>
>
> --
>
>
> Regards,
>
> Steve Tucknott
> ReTSol Ltd
>
> DDI 01903 828769
> MOBILE 07736715772
>
>
>
>
>
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
--

Regards,

Steve Tucknott
ReTSol Ltd

DDI 01903 828769
MOBILE 07736715772




___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Cima 2005-06-30 09:02:52 capring postgresql and mysql
Previous Message Michael Glaesemann 2005-06-30 07:16:44 Re: Aliased table names ...oddity?