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 sql statement right?

Author  Topic 

amitbadgi
Starting Member

29 Posts

Posted - 2005-07-28 : 22:39:05
Hi I wanted to know if the following query is right, can we use 2 inner joins teh way its used here. I am using this query in a vb.net application, but says that there is soem syntax error on the query. The query is as follows

SELECT TOP 25 tblEvent.case_no, tblEvent.entered_by AS Expr1, tblEvent.offender_id, tblEvent.stu_id, tblEvent.date_of_event, tblEvent.offendertype,tblLKP_Location.Location, tblLKP_Offender_type.Offender_type,FROM tblEvent INNER JOIN
tblLKP_Offender_type ON tblEvent.offendertype = tblLKP_Offender_type.offendertypeid INNER JOIN
tblLKP_Location ON tblEvent.location = tblLKP_Location.id
WHERE (tblEvent.entered_by = '" & session("userid") & "')
ORDER BY date_of_event DESC"

Thanks

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2005-07-28 : 23:20:54
Remove the comma between the last fieldname and the FROM clause.

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-29 : 01:32:03
and make sure seesion("userid") is not null

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-07-29 : 08:50:10
and remove it from your ASP page and turn it into a stored proc


*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page

amitbadgi
Starting Member

29 Posts

Posted - 2005-07-30 : 18:14:11
Thankx guys..but also wanted to let u know that I am using an access database, and its giving me an error saying there is some syntactical error...need help..thanx in advance
Go to Top of Page

r937
Posting Yak Master

112 Posts

Posted - 2005-07-31 : 08:03:39
access requires that you parenthesize your joins
select ...
from (
tblEvent
inner
join tblLKP_Offender_type
on tblEvent.offendertype
= tblLKP_Offender_type.offendertypeid
)
inner
join tblLKP_Location
on tblEvent.location
= tblLKP_Location.id
where ...



rudy
http://r937.com/
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-07-31 : 11:32:58
Hi amitbadgi

This is a SQL Server forum, so you might want to also ask in the
Other forums : MS Access
area, or put a link to this topic over there.

Kristen
Go to Top of Page
   

- Advertisement -