[thelist] CF smoke and mirrors
rudy
r937 at interlog.com
Thu Jul 19 16:45:04 CDT 2001
> I always understood that there was no "order" to columns in the
> database, and that to do anything based off the way they are
> ordered in your visual tool (Access, SQL Enterprise Manager, etc)
> was flawed. Any of you database gurus know if this is true, or
> maybe just old school thinking?
grievously flawed
way to go, chris
<tip>
always give the same column used in two tables the same name
example: foreign key referencing a primary key
create table foo (fooid int, foodata varchar(21)
, primary key (fooid) );
poor foreign key naming scheme --
create table bar (barid int, bardata varchar(21)
, barfooid int references foo
, primary key (barid) );
better --
create table bar (barid int, bardata varchar(21)
, fooid int references foo
, primary key (barid) );
yes, whenever you need to use the common column name in a "table list"
join, you need to qualify it using the table name, i.e. foo.fooid or
bar.fooid --
select foodata, bardata
from foo, bar
where foo.fooid = bar.fooid
however, it is now easier to write the join using standard syntax
select foodata, bardata
from foo join bar using fooid
or even
select foodata, bardata
from foo natural join bar
</tip>
rudy
More information about the thelist
mailing list