How to select two tables particular attributes only
there are two tables
Table 1 Select EmployeeID (PK),Employeename,employeecompanyid,employeedepartmentid,employeedob,employeepob from table1;
Table 2 Select EmployeeID(PK),LeaveType(PK),LeaveYear(PK),Numberofleavesavailed from table2;
I want to display particular attribute like this query: the attributes i want to display are Q.1) EmployeeID,EmployeeName from table1 and EmployeeID.LeaveType,LeaveYear from table2 together in one query开发者_JS百科
Now my question i want to display Q.1) both in one query. Any help ?
select t1.EmployeeID,t1.EmployeeName,t2.LeaveType,t2.LeaveYear
from table1 t1 inner join table2 t2 on t2.EmployeeID=t1.EmployeeID
Basically, join the 2 tables using EmployeeID (which is common to the 2 tables) and select the fields you want from each respective table.
精彩评论