On Sat, Sep 19, 2009 at 01:14:56PM -0700, Darren Duncan scratched on the wall:

> 3c.  I would like to have the option for SQLite to never have duplicate 
> unqualified column names; for example, if one said "foo NATURAL INNER
> JOIN bar" then only a single column with the common data would be in
> the result, rather than 2;

  Umm... it does work that way.  That's part of the SQL standard.
  
  NATURAL JOINs and JOIN ... USING( ) will only return one copy of
  each column pair used in the JOIN.

> likewise for inner joins with explicit join conditions of "foo.a = 
> bar.a" would just return a single "a" in the result.

  This goes against the SQL standard and, in this case, I think
  this would be a *very* Bad Idea.  You're taking a command format that
  is designed to take an arbitrary expression and changing the output
  format based off the particulars of that expression.  That strikes me
  as extremely dangerous.  For example, if someone has the first line
  of code and changes it to something like the second line of code,
  suddenly their output changes!

...t1 JOIN t2 ON t1.a = t2.a... => ..., a, ...
...t1 JOIN t2 ON toupper(t1.a) = toupper(t2.a)... => ..., t1.a, t2.a, ...

  If you only want one column because you're using a straight equality,
  use NATURAL or USING.  USING is particularly useful to JOIN across a
  sub-set of the commonly named columns.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to