0

I two tables with different column names except one column id.

Im using below code to join them and also diferentiate the id column from each other.

SELECT a.id as table_id, * 
FROM [CFG].[pipeline_tables] a
LEFT JOIN [CFG].[pipeline_columns] on a.[id]=[pipeline_columns].[pipeline_tables_id]

but id column from pipeline_tables is picked two times ( original name id and new name table_id) and also plus the id columns from pipeline_columns.

Desired out put should be two Id columns with the changed names as table_id and column_id

Thom A
  • 88,727
  • 11
  • 45
  • 75
Greencolor
  • 501
  • 1
  • 5
  • 16
  • Because that's what you asked for; `a.id as table_id, `, `*` means return **every column**. If you don't want to list the `id` of `a` (which is a poor alias for a table named `pipeline_tables`; see [Bad Habits to Kick : Using table aliases like (a, b, c) or (t1, t2, t3)](https://sqlblog.org/2009/10/08/bad-habits-to-kick-using-table-aliases-like-a-b-c-or-t1-t2-t3)) a second time, then explicitly list the columns you want. – Thom A Apr 21 '23 at 08:46
  • don't use *, instead specify every column manually – siggemannen Apr 21 '23 at 08:48

0 Answers0