Skip to content
Advertisement

SQL – join three table with “where” clause

I want to write an SP that I will use in my c# program. I have three tables: Table1 (id pk, name, …), Table2 (id PK, name, …) and Table3((idT1,idT2) PK FK). So, Table3 models the n:n relationship between Table1 and Table2.

I want to retrieve all the Table2.name(s) related to a single Table1.name.

I have already tried to write a query with two inner join

As result, I see more records than are needed. I expected a list of Table2.name related to a single Table1.name (specified by @name parameter)

sorry for my english.

Advertisement

Answer

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement