Re: Counting rows when order is ambiguous

2004-02-26 Thread Sasha Pachev
Philip Mak wrote: Say I have this query: SELECT * FROM topics ORDER BY lastPostTime DESC; How would I modify it to answer the question "How many rows would be returned before the row that has topics.id = $x"? I was thinking of something like this: $xPostTime = SELECT lastPostTime FROM topics WHER

Re: Counting rows when order is ambiguous

2004-02-26 Thread Philip Mak
On Thu, Feb 26, 2004 at 09:50:39AM -0700, Sasha Pachev wrote: > If I understood the problem correctly, the answer to it is actually > undefined. If you order by lastPostTime, the records with the same > lastPostTime value can be returned in any order. > > I guess to accomplish your goal you could

Re: Counting rows when order is ambiguous

2004-02-26 Thread Sasha Pachev
Philip Mak wrote: On Thu, Feb 26, 2004 at 09:50:39AM -0700, Sasha Pachev wrote: If I understood the problem correctly, the answer to it is actually undefined. If you order by lastPostTime, the records with the same lastPostTime value can be returned in any order. I guess to accomplish your goal yo

Re: Counting rows when order is ambiguous

2004-02-26 Thread Philip Mak
On Thu, Feb 26, 2004 at 10:49:08AM -0700, Sasha Pachev wrote: > >SELECT COUNT(*) > >FROM topics > >WHERE lastPostTime > $postTime > >OR (lastPostTime = $postTime AND id > $id); > > Can you just add id > $id to the where clause? No, that won't work because id is only used to disambiguate the order

Re: Counting rows when order is ambiguous

2004-02-26 Thread Sasha Pachev
Philip Mak wrote: On Thu, Feb 26, 2004 at 10:49:08AM -0700, Sasha Pachev wrote: SELECT COUNT(*) FROM topics WHERE lastPostTime > $postTime OR (lastPostTime = $postTime AND id > $id); Can you just add id > $id to the where clause? No, that won't work because id is only used to disambiguate the

Counting rows when order is ambiguous

2004-02-25 Thread Philip Mak
Say I have this query: SELECT * FROM topics ORDER BY lastPostTime DESC; How would I modify it to answer the question "How many rows would be returned before the row that has topics.id = $x"? I was thinking of something like this: $xPostTime = SELECT lastPostTime FROM topics WHERE id = $x; SELE