Click to See Complete Forum and Search --> : Getting First 3 Records in db..


Redhead
02-07-2007, 11:10 AM
Hi There

i'm so so so new to asp and need some help.. i have a db and script that pull everthing.. all i want to try and do know is pull the first 3 records, or the last 3 that were entered in..

i tryed this:

strSQL = "SELECT * FROM tblNews WHERE ID >= 1 AND ID >= 3 ORDER BY NewsDate DESC"


and it dont like that.. is there a way to pull out the last 3 entries in the db??

Thank you..

Redhead
02-07-2007, 11:45 AM
well i got it to work by using

SELECT TOP 2 * FROM tblNews WHERE ShowLive = True ORDER BY NewsDate DESC


but the next thing i was wondering, would i be able to have the title of the news on one page and link it to another.. like anchor it, so it would be 2 pages total one with the full entries, and the other with just title and a link to the first page showing full entry using anchors?? does anyone have any suggestions?:)

zingmatter
02-07-2007, 12:02 PM
<a href="newspage.asp?newsid="<%= othernewsid %>">Other news</a>

and do this...
if len(request.querystring("newid") > 0 then
sql = "select * from tblNews .... where newsid = " & request.querystring("newid")
etc...

Hope that makes sense.