Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 inner joining three tables problem

Author  Topic 

san79
Starting Member

42 Posts

Posted - 2008-05-03 : 10:27:54
hi
i am trying to inner join three tables, after googling some times i found some codes and i tried it resulting some error,
here is my query
SELECT s.staffid,s.staffname,t.ddate,t.intime,t.outtime,t.status,t.hrs,t.totlatetime,t.totearlydep from test t  inner join staffappointment s on (t.empid=s.staffid)   inner join dept_master d on (d.departmentcd=s.department)  where t.edate='20061004';

here is the error
Syntax error missing operator in query expression(t.empid=s.staffid) inner join dept_master d on (d.departmentcd=s.department)

here is the tables involved and its structure

table name staffappointment
fields staffid varchar(10),staffname varchar(50),department int,desig varchar(50)
table name test
fields empid varchar(10),ddate varchar(10),intime int,outtime int,status varchar(10),hrs int,totlatetime int,totearlydep int,edate varchar(10)
table name dept_master
fields departmentcd int,departmentname varchar(50)

if i use where conditions to join then it works fine that query is
SELECT s.staffid,s.staffname,d.departmentname,t.ddate,t.intime,t.outtime,t.status,t.hrs,t.totlatetime,t.totearlydep from test t,staffappointment s,dept_master d where   (t.empid=s.staffid) and (d.departmentcd=s.department)  and t.edate='20061004'

where i am missing in inner join.
@peso sir, how to provide sample data for you guys to work around

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-03 : 10:35:15
[code]SELECT s.staffid,
s.staffname,
t.ddate,
t.intime,
t.outtime,
t.status,
t.hrs,
t.totlatetime,
t.totearlydep
from test t
inner join staffappointment s
on t.empid=s.staffid
inner join dept_master d
on d.departmentcd=s.department
where t.edate='20061004'[/code]
Go to Top of Page
   

- Advertisement -