A well-written driver would then throw an "ambiguous column name" error,
if that happens.

First, you would need to create a table alias:

SELECT t1.*
FROM table1 t1

Then, if you add a column, as you mention, that query would not return
the newly-added column.  You would need to do:

SELECT t1.*, t2.*
FROM table1 t1 INNER JOIN table2 t2 ON t1.id = t2.fk

I don't usually specify table aliases, but this is a good case of why
you should.  When I join tables, however, I do always use a table alias.
It makes it much easier to see where the columns originate.

I also think a "SELECT *" puts a somewhat-larget hit on the DB than
specifying all column names.  I think it is because the DB must look up
all of the column names before it can validate the column names.  If you
specify the column names, then the DB can skip the column name lookup
step before validating the column names.

I'm waiting for Jochem to give the final answer on this...

M!ke

-----Original Message-----
From: Jim [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 11, 2006 10:39 AM
To: CF-Talk
Subject: Re: Select * in SQL

Heres a real world scenario I've come across:

Code throughout the app is using data returned from a query that has
select *, and pulls data from more than one table.
Someone adds a column to one of the tables in the query that has the
same name as a column in another of the tables in the query.

CF now returns a query with 2 columns named the same and your data is
funked up all over the site because using query.columnname is
referencing the wrong column.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/cf_lists/message.cfm/forumid:4/messageid:246124
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to