List:General Discussion« Previous MessageNext Message »
From:Isaac Reuben Date:February 12 2004 1:52pm
Subject:Alias *all* columns in a joined table?
View as plain text  
Say I have two tables, and they have several column names that are the same
in both tables.  I know I can manually alias the column names so that they
don't overlap, but is there a way to prefix *all* of the columns of one
table so that I can be sure the names don't overlap?

So if I have these two tables:

person: id,name,age,home_id
place:  id,name,zip_code

then I could use a query like:

 person.*,place.* as home_*
 person.home_id =
 name = 'Joe'

To get back results like:

The problem is that I don't want to have to update my queries everytime I
add a new column, so I use table_name.* a lot.  But then if I ever add a
column with the same name to another table, I will only get one column or
the other back.

Does MySQL do this?  Should it?

- Isaac

Alias *all* columns in a joined table?Isaac Reuben12 Feb
  • Re: Alias *all* columns in a joined table?Martijn Tonies12 Feb
    • Re: Alias *all* columns in a joined table?Isaac Reuben12 Feb