M
monki
i am trying to write a sql string that pulls a row from a dbase & the rows
either side
i cant use the primary key (autonumber) as some of the records have been
deleted thus there are gaps in the numbering
this is the sql string i have - but it doesnt work
vid is a string passed from a form, NewsId is the primary key
sql="SELECT * FROM tblNews t WHERE t.NewsId="& vid &" OR t.NewsId = (select
max(t.NewsId) t.NewsId WHERE t.NewsId < "& vid &") OR t.NewsId = (SELECT
min(t.NewsId) t.NewsId WHERE t.NewsId > "& vid &") ORDER by t.NewsId; "
can anyone see what is wrong with the sql? i get :-
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error. in query expression 't.NewsId=2 OR t.NewsId = (select
max(t.NewsId) WHERE t.NewsId < 2) OR t.NewsId = (SELECT min(t.NewsId) WHERE
t.NewsId > 2)'.
/geoff/newsalltest.asp, line 23
or is there a better way of doing this?
thanks in advance
j
either side
i cant use the primary key (autonumber) as some of the records have been
deleted thus there are gaps in the numbering
this is the sql string i have - but it doesnt work
vid is a string passed from a form, NewsId is the primary key
sql="SELECT * FROM tblNews t WHERE t.NewsId="& vid &" OR t.NewsId = (select
max(t.NewsId) t.NewsId WHERE t.NewsId < "& vid &") OR t.NewsId = (SELECT
min(t.NewsId) t.NewsId WHERE t.NewsId > "& vid &") ORDER by t.NewsId; "
can anyone see what is wrong with the sql? i get :-
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error. in query expression 't.NewsId=2 OR t.NewsId = (select
max(t.NewsId) WHERE t.NewsId < 2) OR t.NewsId = (SELECT min(t.NewsId) WHERE
t.NewsId > 2)'.
/geoff/newsalltest.asp, line 23
or is there a better way of doing this?
thanks in advance
j