Re: [SQL] ORDER BY does not work as expected with multiple joins

2006-01-13 Thread Jaime Casanova
On 1/13/06, Adam Rosi-Kessel <[EMAIL PROTECTED]> wrote: > Tom Lane wrote: > > Adam Rosi-Kessel <[EMAIL PROTECTED]> writes: > >> I have a multijoin SELECT statement where the ORDER BY clause doesn't > >> seem to be working. > > You haven't mentioned your Postgres version, nor provided anywhere near

Re: [SQL] ORDER BY does not work as expected with multiple joins

2006-01-13 Thread Michael Glaesemann
On Jan 14, 2006, at 0:45 , Michael Glaesemann wrote: On Jan 14, 2006, at 0:22 , Adam Rosi-Kessel wrote: id1 will always have a value but id2 can be NULL. So should I do a left JOIN on id2 but a plain JOIN on id1? Is there a disadvantage to using a left JOIN where it is not necessary? I

Re: [SQL] ORDER BY does not work as expected with multiple joins

2006-01-13 Thread Tom Lane
Adam Rosi-Kessel <[EMAIL PROTECTED]> writes: > But I am curious why you think a LEFT JOIN should be used rather than RIGHT > JOIN? I think I believe I am getting the desired set of records. When I > substitute LEFT JOIN for RIGHT JOIN I actually get the same result. Can you > help me understand und

Re: [SQL] ORDER BY does not work as expected with multiple joins

2006-01-13 Thread Michael Glaesemann
On Jan 14, 2006, at 0:22 , Adam Rosi-Kessel wrote: id1 will always have a value but id2 can be NULL. So should I do a left JOIN on id2 but a plain JOIN on id1? Is there a disadvantage to using a left JOIN where it is not necessary? In that case, yes, I'd JOIN on id1 and LEFT JOIN on id2.

Re: [SQL] ORDER BY does not work as expected with multiple joins

2006-01-13 Thread Adam Rosi-Kessel
Thanks for your helpful response. Michael Glaesemann wrote: > I don't seem to have a problem with the ordering given your data. I'm > not sure why you're doing right and left joins, though. You might want > to use left joins if you have NULL id1 or id2, but otherwise just plain > JOIN should work

Re: [SQL] ORDER BY does not work as expected with multiple joins

2006-01-13 Thread Michael Glaesemann
On Jan 13, 2006, at 23:32 , Adam Rosi-Kessel wrote: I have a multijoin SELECT statement where the ORDER BY clause doesn't seem to be working. I can't figure out how pgsql is sorting the results, but it is definitely different from the same list without the multiple joins. What I am trying

Re: [SQL] ORDER BY does not work as expected with multiple joins

2006-01-13 Thread Adam Rosi-Kessel
Tom Lane wrote: > Adam Rosi-Kessel <[EMAIL PROTECTED]> writes: >> I have a multijoin SELECT statement where the ORDER BY clause doesn't >> seem to be working. > You haven't mentioned your Postgres version, nor provided anywhere near > enough information to let other people reproduce the problem. Y

Re: [SQL] ORDER BY does not work as expected with multiple joins

2006-01-13 Thread Tom Lane
Adam Rosi-Kessel <[EMAIL PROTECTED]> writes: > I have a multijoin SELECT statement where the ORDER BY clause doesn't > seem to be working. You haven't mentioned your Postgres version, nor provided anywhere near enough information to let other people reproduce the problem. You might find it helpfu