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)
 is this query right

Author  Topic 

amitbadgi
Starting Member

29 Posts

Posted - 2005-08-11 : 13:47:40
i am using this query for a .net project against an ms access database, its giving me an error saying that "syntax error in join operation", pls let me know where i went wrong, thanx

SELECT tblEvent.case_no, tblEvent.date_of_event, tblLKP_Event_type.name,tblEvent_type.eventtypedesc,tblEvent_type.event_type_id,tblLKP_Location.dorm FROM ((tblEvent_type INNER JOIN tblEvent ON tblEvent_type.case_no = tblEvent.case_no, tblLKP_Event_type ON tblEvent_type.event_type_id = tblLKP_Event_type.id) INNER JOIN tblLKP_Location ON tblEvent.location = tblLKP_Location.id) WHERE (tblEvent_type.event_type_id = 1 or tblEvent_type.event_type_id = 3) AND (tblEvent.date_of_event > '1/1/" + Replace(rs_damg_list__cyear, "'", "''") + "' and tblEvent.date_of_event < '12/31/" + Replace(rs_damg_list__cyear, "'", "''") + "') AND (tblLKP_Location.dorm = 'Y')"

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-08-11 : 14:02:45
Here's a shot!


SELECT tblEvent.case_no, tblEvent.date_of_event, tblLKP_Event_type.name,tblEvent_type.eventtypedesc,tblEvent_type.event_type_id,tblLKP_Location.dorm FROM ((tblEvent_type INNER JOIN tblEvent ON tblEvent_type.case_no = tblEvent.case_no, tblLKP_Event_type ON tblEvent_type.event_type_id = tblLKP_Event_type.id) INNER JOIN tblLKP_Location ON tblEvent.location = tblLKP_Location.id) WHERE (tblEvent_type.event_type_id = 1 or tblEvent_type.event_type_id = 3) AND (tblEvent.date_of_event > '1/1/" + Replace(rs_damg_list__cyear, "'", "''") + "' and tblEvent.date_of_event < '12/31/" + Replace(rs_damg_list__cyear, "'", "''") + "') AND (tblLKP_Location.dorm = 'Y')"


SELECT
tblEvent.case_no,
tblEvent.date_of_event,
tblLKP_Event_type.name,
tblEvent_type.eventtypedesc,
tblEvent_type.event_type_id,
tblLKP_Location.dorm
FROM tblEvent_type
INNER JOIN tblEvent
ON tblEvent_type.case_no = tblEvent.case_no
Inner Join tblLKP_Event_type
ON tblEvent_type.event_type_id = tblLKP_Event_type.id
INNER JOIN tblLKP_Location
ON tblEvent.location = tblLKP_Location.id
WHERE
(tblEvent_type.event_type_id = 1
or
tblEvent_type.event_type_id = 3)
AND tblEvent.date_of_event > '1/1/" & Replace(rs_damg_list__cyear, "'", "''") & "'
and tblEvent.date_of_event < '12/31/" & Replace(rs_damg_list__cyear, "'", "''") & "'
AND tblLKP_Location.dorm = 'Y'


Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page

amitbadgi
Starting Member

29 Posts

Posted - 2005-08-12 : 01:41:33
Thanx it worked just fine.
Go to Top of Page
   

- Advertisement -