Skip site navigation (1) Skip section navigation (2)

Re: select issue with order v8.1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Terry <td3201(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select issue with order v8.1
Date: 2010-02-25 04:07:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Terry <td3201(at)gmail(dot)com> writes:
> I have an application that is doing something stupid in that it is
> tacking on its own order clause at the end of the statement I am
> providing.

> For example, I am putting this statement in:
> select ev_id,type,ev_time,category,error,ev_text,userid,ex_long,client_ex_long,ex_text
> from clients_event_log limit 100

> It is tacking on ORDER BY ev_id.  The problem is that isn't per the
> syntax.  Can anyone think of anything clever to get around this stupid
> application doing what it is doing?  For example, anything I can do
> beside limit?

Hrm, fix the application?

You might be able to make a go out of something along the lines of

select ev_id,... from (select * from clients_event_log limit 100) as ss;

which would admit an ORDER BY on the end.

BTW, in most cases it doesn't make any sense to have a LIMIT without an
ORDER BY inside the subselect --- unless you really don't care which 100
rows you get.

			regards, tom lane

In response to

pgsql-general by date

Next:From: Scott MarloweDate: 2010-02-25 04:30:55
Subject: Re: select issue with order v8.1
Previous:From: TerryDate: 2010-02-25 03:50:19
Subject: select issue with order v8.1

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group