Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select same column from two tables
Message
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Select same column from two tables
Miscellaneous
Thread ID:
01647947
Message ID:
01647947
Views:
57
Hi,

I see the following behavior of SQL Select, when both parent and child tables have the same field name and joined in SQL Select. And the value is set in the column that is shown first in the SQL Select order. Here is an example:
select ChildTable.FIELD_X, ParentTable.* from ParentTable JOIN ChildTable on ParentTable.Pk = ChildTable.Pk
Note that the ParentTable also has field FIELD_X but the resulting query shows the value of FIELD_X from the ChildTable.
Is this by design that since the column FIELD_X shows before the ParentTable.* it takes precedence?

TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View

Click here to load this message in the networking platform