1

Is there a way to automate dealing with/ignoring duplicate names when creating a new table in Teradata.

Assume I'm joining a table with itself. The table has columns

id, email, address1, address2, city, state, zip.

,

create table mytable2 as (
  select a.*, b.* from mytable a
  left join mytable b on a.email = b.email
  where a.id <> b.id
) with data

requires me to write out

a.address1 as aaddress1, b.address1 as baddress1, a.address2 as aaddress2...

Is there an easier way of dealing with this? When I'm joining many tables, this hurts my productivity. Often these tables are for research and the potential ambiguity is not a problem.

artdv
  • 774
  • 1
  • 8
  • 23
  • 3
    No way. When you create a table you must assign unique names. – dnoeth Aug 07 '14 at 09:46
  • This sounds like this table is part of a bigger problem you are trying to solve. Purely on face value from the SQL you have provided you have a self-join on a table looking for records that share the same email address. Is the `id` column a surrogate for the `email` as the natural primary key? – Rob Paller Aug 07 '14 at 21:04

0 Answers0