List:General Discussion« Previous MessageNext Message »
From:Joerg Bruehe Date:May 7 2005 10:36am
Subject:Re: amPiguous!
View as plain text  
Hi!

Dan Bolser wrote:
> [[...]]
> 
> I would have said...
> 
> select pk from a inner join b on a.pk = b.pk;
> 
> (probably pk was a bad choice for an example column name).
> 
> Using the ON syntax instead of the USING syntax makes my problem look even
> more silly than it already is, i.e. just say
> 
> select a.pk from a inner join b on a.pk = b.pk;
> 
> Thing is I use the USING syntax all the time and name equivelent columns
> in different tables the same to help me do this (I read somewhere that
> this is good practice).
> 
> Is it still me, or should the USING syntax 'disambiguate' columns in the
> select statement?


IMO, it "should" not - it "might", but no stronger desire.

Remember that we are talking about syntax here, not semantics!

It is a requirement of the SQL syntax that the column names in the 
"select list" be unique in the tables listed in the "from clause", and 
if the plain names are ambiguous, they must be qualified with the table 
name.

What you would like to see is a special case handling of an equality 
constraint. Sure this is possible, but as a consequence
    SELECT pk FROM a, b WHERE a.pk = b.pk
would be valid (or "desired valid"), whereas
    SELECT pk FROM a, b WHERE a.pk > b.pk
would be (and always remain) invalid. From a syntactic point, this would 
be very hard to argue.
I propose you simply use
    SELECT a.pk FROM a, b WHERE a.pk = b.pk
and all is fine.

Regards,
Jörg
Thread
amPiguous!Dan Bolser7 May
  • Re: amPiguous!Rhino7 May
    • Re: amPiguous!Simon Garner7 May
      • Re: amPiguous!Dan Bolser7 May
    • Re: amPiguous!Eric Jensen7 May
      • Re: amPiguous!Eric Bergen7 May
        • Re: amPiguous!Dan Bolser7 May
          • Re: amPiguous!Chris7 May
            • Re: amPiguous!Jochem van Dieten7 May
    • Re: amPiguous!Dan Bolser7 May
      • Re: amPiguous!Joerg Bruehe7 May
  • Re: amPiguous!Rhino7 May
  • Re: amPiguous!Jochem van Dieten7 May
    • Re: amPiguous!Dan Bolser7 May
      • Re: amPiguous!Jochem van Dieten7 May
        • Re: amPiguous!Dan Bolser15 May