Mayank Jani

Mayank Jani

  • NA
  • 477
  • 76.7k

How to join three tables in a query.

Aug 24 2017 2:11 PM
Hello Dear Friends,
 
I am learning C# winapp and i want to create a query with three tables. I know how to join two tables with inner join but i got error while doing the same with three tables. 
here is my tables structure...
 
1.Table Employee

EmpName     Text
EmpAdd         Text
EmpCityId       Number
EmpStatId       Number

2.Table MasterCity

CityId       Number
StateId    Number
City          Text

3.Table MasterState

StateId    Number
State       Text

I want to get a record from employee table. How can I join three tables that give me a full record of an employee with name, address, city and state?
 
I am trying with >  Select Employee.empname, Employee.empadd, Mastercity.city, Masterstate.state from Employee inner join mastercity on Employee.empcityid=
mastercity.cityid inner join employee.empstateid=masterstate.stateid Where Employee.EmpName='PINAKIN T SHAH'
 
Please help out with how to correct the query? How to join three tables?
 
Thank You
 
Mayank Jani

Answers (14)