Reputation: 843
Im in a position where I cannot alter the table structure of my database and I have Ambiguous Column Names in [table1] and [table2]. I do not need to use any fields from [table2] but its existence is necessary to relate to another table. Is there a way that I handle this?
Upvotes: 1
Views: 2581
Reputation: 2445
use the SQL statement AS to create uniquel names
SELECT
A.feld1 AS F1,
A.feld2 AS F2,
B.feld1 AS F3
FROM table1 AS A
JOIN table2 AS B ON A.id = B.id
ORDER BY A.field1
Upvotes: 1
Reputation: 6873
use table aliases
SELECT A.*
FROM TABLE_A A
JOIN TABLE_B B ON A.ID = B.ID
ORDER BY A.FIELD
Upvotes: 3
Reputation: 838256
Every time you refer to one of the ambiguous column names you should specify the table name or alias.
SELECT ...
FROM [table1]
JOIN [table2]
ON [table1].ambiguous_column = [table2].ambiguous_column
AND ...
Upvotes: 5