Querying 2/3 tables with one SQL statement

mvlseanz2

New Member
I have three tables: \[code\]users, projects, user_project\[/code\]\[code\]user_project\[/code\] contains \[code\]user_id, project_id\[/code\] and \[code\]role_id\[/code\], where \[code\]user_id\[/code\] and \[code\]project_id\[/code\] are both primary keys connected to \[code\]projects.project_id\[/code\] and \[code\]users.user_id\[/code\].I want to get the the name and surname of all the users from the \[code\]users\[/code\] table that has to do with a certain project from the \[code\]projects\[/code\] table through \[code\]user_project\[/code\].What SQL statement do I have to use? I was thinking something like this:\[code\]SELECT users.name, users.surname FROM users WHERE users.user_id = user_project.user_id AND projects.project_id = @parameter\[/code\]I am using SQL Server 2012 and ASP.NET/VB.NET.
 
Back
Top