Select A,A from .... 2 fields with different values,
I have two tables in Sql Server. The first one called "Details"
(1)IdUser
(2)IdUser2
(3)ProcessDescription
The second Table Users:
(1)IdUser
(2)Name
I need to see both User1 and User2 for each register in Details but don´t know how to do that.
Select Users.Name,Users.Name from Users inner join ...... ?????
(1)IdUser
(2)IdUser2
(3)ProcessDescription
The second Table Users:
(1)IdUser
(2)Name
I need to see both User1 and User2 for each register in Details but don´t know how to do that.
Select Users.Name,Users.Name from Users inner join ...... ?????
SELECT Users.IdUser, Details.IdUser2, Users.Name, Details.ProcessDescription From Users LEFT JOIN Details ON Details.IdUser = Users.IdUser ORDER BY Users.IdUser;
The above will show up all the records from the Users table and only those of Details whose IdUser field match the IdUser field in the Users Table...
If, on the other hand, you want to see all the records from the Details table along with their correspondent Name from the Users table, then use the next:
SELECT Details.IdUser, Details.IdUser2, Users.Name, Details.ProcessDescription From Details LEFT JOIN Users ON Details.IdUser = Users.IdUser ORDER BY Details.IdUser;
Hope this is what you need ...
Cheers !
If, on the other hand, you want to see all the records from the Details table along with their correspondent Name from the Users table, then use the next:
SELECT Details.IdUser, Details.IdUser2, Users.Name, Details.ProcessDescription From Details LEFT JOIN Users ON Details.IdUser = Users.IdUser ORDER BY Details.IdUser;
Hope this is what you need ...
Cheers !
