I have three tables with column types: (id, type, creation). When I
do a Select statement I want to have them prefixed with the table
alias without aliasing each individual column with an AS statement.
I DON?T want to write out the fields like:
SELECT
T1.id AS t1_id,
T1.type AS t1_type,
T1.creation AS t1_creation,
T2.id AS t2_id,
T2.type AS t2_type,
T2.creation AS t2_creation,
T3.id AS t3_id,
T3.type AS t3_type,
T3.creation AS t3_creation
I NEED a way to have them prefixed by the table alias, so I can use either
SELECT *
OR
SELECT
T1.*,
T2.*,
T3.*
Without having to prefix the individual columns.
A function to prefix the tables is fine for an answer. We are
currently using Postrgres. |
Clarification of Question by
johnsmithms-ga
on
24 Aug 2006 17:26 PDT
The solution needs to work with any database table...
An example of something we're looking for might be:
SELECT
magicfunction(T1.*, "t1_"),
magicfunction(T2.*, "t2_"),
magicfunction(T3.*, "t3_")
WHERE
T1.id = T2.id AND
T3.id = T2.id
The result would comeback with all results prefixed appropriately
and respectively t1_... t2_... and t3_...
|