Thread: ordering rows
Hi
I have a table 'import' which is an amalgam of two other tables 'loops' and 'devices'.
The ID column of loops is reflected in the import table. However the order of rows ends up as, a for instance, 6, 8, 7, 4, 5 3, 2, 1.
I need to fetch these rows one at a time, in sequence with the loop ID, to process them in a delphi interface before going on to the next row.
Query-
1. Can I somehow ensure that the rows are transfered to the import table in numerical sequence with the ID of the loop table?
2. Is there a method of using the fetch command to ensure that rows are picked up sequentially - lowest ID to highest ID or vice-versa?
3. Is there another mehod of accomplishing this task other than fetch?
Bob Pawley
Bob Pawley wrote: > Hi > > I have a table 'import' which is an amalgam of two other tables > 'loops' and 'devices'. > > The ID column of loops is reflected in the import table. However the > order of rows ends up as, a for instance, 6, 8, 7, 4, 5 3, 2, 1. These are the IDs from loops? > I need to fetch these rows one at a time, in sequence with the loop > ID, to process them in a delphi interface before going on to the next > row. ORDER BY loops.id ASC > Query- > > 1. Can I somehow ensure that the rows are transfered to the import > table in numerical sequence with the ID of the loop table? Ensure that *what* is transferred? The rows from imports? Do they have a foreign key pointing to loops? > 2. Is there a method of using the fetch command to ensure that rows > are picked up sequentially - lowest ID to highest ID or vice-versa? > > 3. Is there another mehod of accomplishing this task other than > fetch? > Perhaps you should post your SELECT statement and a sample of the result you're getting (and a sample of what you desire to get wouldn't hurt). brian
That's marvelous - thanks. Bob ----- Original Message ----- From: "brian" <brian@zijn-digital.com> To: <pgsql-general@postgresql.org> Sent: Thursday, October 18, 2007 9:45 AM Subject: Re: [GENERAL] ordering rows > Bob Pawley wrote: >> Hi >> >> I have a table 'import' which is an amalgam of two other tables >> 'loops' and 'devices'. >> >> The ID column of loops is reflected in the import table. However the >> order of rows ends up as, a for instance, 6, 8, 7, 4, 5 3, 2, 1. > > These are the IDs from loops? > >> I need to fetch these rows one at a time, in sequence with the loop >> ID, to process them in a delphi interface before going on to the next >> row. > > ORDER BY loops.id ASC > >> Query- >> >> 1. Can I somehow ensure that the rows are transfered to the import >> table in numerical sequence with the ID of the loop table? > > Ensure that *what* is transferred? The rows from imports? Do they have a > foreign key pointing to loops? > >> 2. Is there a method of using the fetch command to ensure that rows >> are picked up sequentially - lowest ID to highest ID or vice-versa? >> >> 3. Is there another mehod of accomplishing this task other than >> fetch? >> > > Perhaps you should post your SELECT statement and a sample of the result > you're getting (and a sample of what you desire to get wouldn't hurt). > > brian > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings