MySQL Lists are EOL. Please join:

List:MySQL and .NET« Previous MessageNext Message »
From:Kevin Turner Date:May 31 2005 10:27pm
Subject:RE: How to get full column name (table name and column name) from query results?
View as plain text  

I think I am still at a loss to work out what you are trying to achieve. Sounds like you
are doing a lot of unnecessary processing but I am sure you have a reason.

-----Original Message-----
From: Bob Dankert [mailto:bob@stripped] 
Sent: 31 May 2005 20:01
To: dotnet@stripped
Subject: RE: How to get full column name (table name and column name) from query results?

I was able to get the information I need from DataReader.GetSchemaTable and referencing
the BaseTableName for each column returned.

Bob

Envision Information Technologies
Associate
bob@stripped
v. 608.256.5680
f. 608.256.3780
 

-----Original Message-----
From: Andrés Villanueva [mailto:xal1983@stripped] 
Sent: Tuesday, May 31, 2005 1:30 PM
To: dotnet@stripped
Subject: Re: How to get full column name (table name and column name) from query results?

I think that what you are trying to do is this:

select t1.name as name1, t1.table1id, t2.name as name2, t2.table2id 
table1 t1 inner join table2 t2 on t1.<column> = t2.<column>;


Regards!!

Andrés Villanueva

P.S.: As a rule, I try to NEVER do a "select *", because this kind of 
conflicts may arise. In fact other sql engines won't let the query run 
if you are querying for two columns with the same name (even if they 
contain different data).


Bob Dankert wrote:

>My issue is not with the query, it does not matter how I join the
>tables.  Let me explain this better with an example.  I have two tables,
>`table1` and `table2`.  `table1` has 2 columns:  `name` and `table1id`,
>and `table2` has 2 columns:  `name` and `table2id`.  If I do the
>following query: select * from table1 join table2 on table1.table1id =
>table2.table2id;
>
>I will get back the following columns:  table1.name, table1.table1id,
>table2.name, table2.table2id
>
>But, using the DataReader.GetName() command, it will return the
>following:
>"name","table1id","name","table2id"
>
>This can cause confusion unless the program can figure out which table
>the data is coming from.  I *think* I may be able to get this using
>DataReader.GetSchemaTable(), but I am still investigating this.
>
>Any further help would be appreciated.
>
>Bob Dankert
>
>Envision Information Technologies
>Associate
>bob@stripped
>v. 608.256.5680
>f. 608.256.3780
> 
>
>-----Original Message-----
>From: Kevin Turner [mailto:kevin.turner@stripped] 
>Sent: Tuesday, May 31, 2005 12:47 PM
>To: dotnet@stripped
>Subject: RE: How to get full column name (table name and column name)
>from query results?
>
> 
>Rather than the USING clause couldn't you use the ON clause, i.e.
>
>select * from table1 as t1 join table2 as t2 on t1.<column> =
>t2.<column>;
>
>Where <column> is the name of your (duplicate) column in each table.
>
>-----Original Message-----
>From: Bob Dankert [mailto:bob@stripped] 
>Sent: 31 May 2005 16:53
>To: dotnet@stripped
>Subject: How to get full column name (table name and column name) from
>query results?
>
>Using the MySqlDataReader to get the results from a query, is it
>possible to get the full columns names from the DataReader (table name
>and column name)?  I have many queries that join tables with the same
>column names, and to distinguish which column is which I would like to
>know the table name as well as column name.  Currently, I get the column
>name from MySqlDataReader.GetName(index), and the query is rather
>general:  select * from table1 join table2 using (index);
>
> 
>
>Thanks,
>
> 
>
>Bob
>
> 
>
>Envision Information Technologies
>
>Associate
>
>bob@stripped
>
>v. 608.256.5680
>
>f. 608.256.3780
>
> 
>
> 
>
>
>
>
>"NOTICE: The information in this electronic mail transmission is
>intended by CoralTree Systems Ltd for the use of the named individuals
>or entity to which it is directed and may contain information that is
>privileged or otherwise confidential. If you have received this
>electronic mail transmission in error, please delete it from your system
>without copying or forwarding it, and notify the sender of the error by
>reply email or by telephone, so that the sender's address records can be
>corrected."
>
>
>  
>


-- 
MySQL on .NET Mailing List
For list archives: http://lists.mysql.com/dotnet
To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1


-- 
MySQL on .NET Mailing List
For list archives: http://lists.mysql.com/dotnet
To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1


-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.2.0 - Release Date: 27/05/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.2.0 - Release Date: 27/05/2005
 

"NOTICE: The information in this electronic mail transmission is intended by CoralTree
Systems Ltd for the use of the named individuals or entity to which it is directed and may
contain information that is privileged or otherwise confidential. If you have received
this electronic mail transmission in error, please delete it from your system without
copying or forwarding it, and notify the sender of the error by reply email or by
telephone, so that the sender's address records can be corrected."

Thread
How to get full column name (table name and column name) from query results?Bob Dankert31 May
RE: How to get full column name (table name and column name) from query results?Kevin Turner31 May
RE: How to get full column name (table name and column name) from query results?Bob Dankert31 May
  • Re: How to get full column name (table name and column name) fromquery results?AndrĂ©s Villanueva31 May
RE: How to get full column name (table name and column name) from query results?Kevin Turner31 May
RE: How to get full column name (table name and column name) from query results?Bob Dankert31 May
  • RE: How to get full column name (table name and column name) from query results?Jerome Wilson1 Jun
RE: How to get full column name (table name and column name) from query results?Kevin Turner1 Jun