MySQL Forums
Forum List  »  General

Dynamic aliasing of columns?
Posted by: andy
Date: March 11, 2005 06:26PM

Hi,
I was wondering if there is anyway to dynamically alias results from query. For example, I'd like to be able to send a query like:

SELECT (table1.*)table1_columnname, (table2.*)table2_columnname FROM table1 JOIN table2 ON table1.id = table2.table1Id

My application is that I have a contacts table that many different database entities use to keep basic info, and, when I'm returning things, sometimes I will be returning a pair of entities that both reference that, thus they will be returning the same column names unless I do something like:

SELECT (table1.column1)table1_column1, (table1.column2)table1_column2, (table2.column1)table2_column1, (table2.column2)table2_column2 FROM table1 JOIN table2 ON table1.id = table2.table1Id

I know I can do the second option, and I have been doing it, but I was just wondering if there is an easier way to do it.

Options: ReplyQuote


Subject
Written By
Posted
Dynamic aliasing of columns?
March 11, 2005 06:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.