A
A
Anton2015-12-23 22:05:39
SQL
Anton, 2015-12-23 22:05:39

How to fix field name conflict in INNER JOIN (T-SQL)?

Hello!
Let's say there are several tables that need to be linked. Some of us have "title" fields. So, because of this coincidence, an error comes out, and specifically, in a new table (after all, the function returns a table value) there cannot be two columns with the same names. Everything is logical.
The question is how to fix it? For example, in SELECT prescribes all these fields "title", and below we rename them. How to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kovalsky, 2015-12-23
@hummingbird

Elementary.

SELECT t.title as t1Title, t2.title as t2Title FROM table1 as t
INNER JOIN table2 as t2 ON t2.id = t.id

The word AS can work wonders.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question