Selecting fields with the same name from 2 tables

  • Thread starter Thread starter rettigcd
  • Start date Start date
R

rettigcd

Every table in my db has these 3 fields: Created, Modified, and
Expired.

3 of my tables are Person, Business, and Employment.

So Person.Created and Person.Expired store when a person is born and
dies.
Employment.Created and Employment.Expired store when a person starts
and quits a job.

I am trying to select every person for a given employer in 1 select
statement:

SELECT person.*,employment.* FROM employment JOIN /*DELETED*/ WHERE
employment.employer_id = 1;

When I use an IDataReader and try to get the expiration date of
employment, I get the date the person died.

while( reader.Read() ){
object end_of_employment = reader["expired"]; // error! returns
death
}

How can I make the IDataReader distinguish between "person.expired" and
"employment.expired"? I don't want to use int indexes if I can help
it. And I can't alias the individual fields because I have to use the
tablename.* format.

thanks.
Dean Rettig
 
Back
Top