OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

Help with a Query

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> Help with a Query
Page: [1]
 
dzirkelb1

 

Posts: 1433
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
Help with a Query - 10/20/2009 12:24:33   
I have a situation where I wish to grab the next record in a recordset, but only that record. I can't use math to add 1 to it and find out, as they can skip. It might be easier to show with an example:

SELECT TOP 100 PERCENT [QUOTE #] AS Expr1, QteLineSerialNbr AS Expr2
FROM dbo.[QUOTES DETAIL]
WHERE ([QUOTE #] = 288753)
ORDER BY QteLineSerialNbr

results:

9
11
13
14
15
18
22
23
24

So, lets say I want to grab the result 13 and 9, how do I do that? Do I have to place it into an array and grab it or is there an easier alternative?
bobby

 

Posts: 11479
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: Help with a Query - 10/22/2009 19:01:23   
It is hard to know exactly what you're trying to do from your description...

You returned the records as requested... why are you wanting only 13 and 9? Is there a criteria for selecting those out? Do you want it returned in that order? 13 and then 9? Or is 9 and then 13 okay?

If possible, make your initial query more specific to pull out exactly which records you want the first time. If that isn't possible then we need to delve deeper...

_____________________________

Talk to your kittens about catnip, or someone else will.


:)

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1433
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: Help with a Query - 10/23/2009 12:44:27   
What I am doing is having a Next and Previous link for the database. However, it's a little different than normal as the autonumber can skip, sort of.

Quote 123456 has the following line id's

1
2
3
5
6
8

Quote 234567 has teh following id's
4
7
9
10

the line id is an autonumber, but, you can add lines to a quote whenever you want...hence, the skipping.

What I am currently doing is this:

SELECT QteLineSerialNbr FROM [QUOTES DETAIL] WHERE (QteLineSerialNbr > "&intQteLineSerialNbr&")"

Where the variable is the current qtelineserialnbr for that page. Then, I just do the following:

if not rs.eof then
intNextQteLineSerialNbr = rs("QteLineSerialNbr")
end if

And, opposite for previous.

However, that query is pulling all results of the query...maybe I should do a MIN command with a having clause on the qtelineserialnbr?

(in reply to bobby)
bobby

 

Posts: 11479
Joined: 8/15/1969
From: Seattle WA USA
Status: offline

 
RE: Help with a Query - 10/23/2009 19:43:03   
So if I understand correctly... instead of getting this result:

Quote 234567 has teh following id's
4
7
9
10

You are getting this?

Quote 234567 has teh following id's
4
5
6
7
8
9
10

sorry if I'm still not getting it...

Does each quote line have a unique ID that relates to the database table? Without knowing the structure of your database I would say it has to do with the relationship between tables... if the relationships are not set up correctly you can get all kinds of funky returns...

It could be that you need a M:M related table to pull recordsets from where the lines have already been assigned to the pertinent quote..?

Did you design the relational structure of the database when you built it? Layout and design of a relational database (which is what you're dealing with) is as crucial as the SQL queries you write to it.


_____________________________

Talk to your kittens about catnip, or someone else will.


:)

(in reply to dzirkelb1)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> Help with a Query
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts