473,799 Members | 2,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

position of a certain record in the result set?

Hi all,

Is there a way to find the position of a certain record (id) in a result
set, based on a (autonumber id)?

Example:
My table has 2 fields: id & name, and the contents =
id name
1 Hi
2 There
3 This
4 Is
5 A
6 Quesion
7 But
8 Is
9 It
10 Possible

Say the currently selected record is id=2 > this is the 2nd record in the
result set.

Say i show only 2 records per page, and the set is sorted by id

Select * from mytable order by id asc limit 0,2
will give:

1 Hi
2 There

Now, as my id = 2 (currently selected record), and the selected record is
the 2nd record in the total result set (no limit), but also the second
record of the first page (offset = 0)

if I change the sort order to name, asc, I still want the selected record
(id=2) to be show, so the page that record is on should be calculated:

Select * from mytable order by id asc limit 0,2 will show only the records 5
& 8, so I need to calculate a new offset.

5 A
7 But
1 Hi
4 Is
8 Is
9 It
10 Possible
6 Quesion
2 There
3 This

and now my id =2 is the 8th record in the result set... (or the first record
in the 5th page) (=10records/2 records per page)

Ronald
Compad
Jul 19 '05 #1
0 2165

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1918
by: SAN CAZIANO | last post by:
How can I display all the record of a certain field in a combobox after I have connected to a db in mysql ??? thanks a lot -- Alberto
20
10166
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
0
537
by: Ronald van Raaphorst | last post by:
Hi all, Is there a way to find the position of a certain record (id) in a result set, based on a (autonumber id)? Example: My table has 2 fields: id & name, and the contents = id name 1 Hi 2 There
4
2779
by: CH | last post by:
Hi, I recently encountered a problem while trying to create a report grouped by certain time frames. However, Access only allows grouping in Minutes or Hours. For example, the first time frame is from 5:30am to 6:20am, if I have record 1 with time = 5:30am, record 2 with time = 6:00am and record 3 with time = 6:30am, the report will group record 1, 2 & 3 together under 5:30am (if grouped on Minute) Or group record 1 under 5:30am and...
7
22409
by: Eric | last post by:
I am trying to save the "last read" position of a file using a StreamReader object. I am reading the lines of the file using StreamReader.ReadLine and then saving the current position in the file. My problem is that on subsequent reads, the starting position is not correct. I have tried many different ways to increment the file position value, but I cannot get it to work so that on the next read, the read starts at the correct...
3
1778
by: Mark Vergara | last post by:
Hi to all, I want to know if there is a way of getting the position of the particular record in the dataset aside from CurrencyManger.position let say for example we have a record.. cntID Name 1 Richard 2 Lucas 3 Jesus
0
871
by: Emee | last post by:
Hi, Could someone please help me with this: I've got a list of employees grouped by Department and then Possition. The names of the employees are listed in the Details section. I've created a subreport also in the Details section which does the running total of each employees pay in a given period. I've created a shared variables to assign these running totals in the
0
1137
by: jegathees | last post by:
Hi Friends, I am working in SAP XI Platform. In this, we use XSLT Mapping. I am facing one problem to print in field 'RecordID' starts from 1,2,3 in the target structure for those records received in the target side based on condition I explain my problem clearly. My source strucutre (with data) is like below. --------------------------------
3
2525
by: magix | last post by:
How can I search for occurance of a character in certain position of a string I checked function strchr, but doesn't option to specify position. Thanks. Regards, Magix
0
9686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10250
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.