'How to avoid repeated columns in a join query? [duplicate]
For example, create two related tables:
create table tableA(id int identity primary key not null, columna2 varchar(10), columna3 varchar(10))
create table tableB(id int identity foreign key references tableA not null, columnaB varchar(10), columnaC varchar(10))
And then perform the join:
select *from tableA a inner join tableB b on a.id=b.id
How to avoid that the column id does not appear twice since they will have the same data assuming that the tables have many more columns and specifying column by column is not what you want.
Solution 1:[1]
You must write all column name of two tables. I hope it will help you.
select
a.id
,a.columna2
,a.columna3
,b.columnaB
,b.columnaC
from tableA a inner join tableB b on a.id=b.id
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tien Nguyen Ngoc |
