Re: [PHP] psql with PHP question

From: Joel Burton <jburton(at)scw(dot)org>
To: Gyozo Papp <pgerzson(at)freestart(dot)hu>
Cc: Jason <gee308(at)mediaone(dot)net>, pgsql-php(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: [PHP] psql with PHP question
Date: 2001-05-04 20:15:21
Message-ID: Pine.LNX.4.21.0105041614260.1389-100000@olympus.scw.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-php

On Thu, 3 May 2001, Gyozo Papp wrote:

> In my opinion, these queries make the same :
> SELECT id FROM article WHERE id=(SELECT MAX(id) FROM article);
> SELECT MAX(id) FROM article;
>
> but the latter one is much more simple and you do not overload your pg.
> (by the way, I think id = (SELECT ...) isn't handled gracefully.)

Yep, it's much better.

If you want to get more than just the ID, try:

select * from article order by id desc limit 1;

HTH,
--
Joel Burton <jburton(at)scw(dot)org>
Director of Information Systems, Support Center of Washington

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Coers 2001-05-04 20:31:56 commit_delay
Previous Message Stephan Szabo 2001-05-04 19:59:54 Re: a primer on trigger?

Browse pgsql-novice by date

  From Date Subject
Next Message rbird 2001-05-04 20:49:51 Install of postgresql
Previous Message Tom Lane 2001-05-04 16:41:32 Re: UPDATE and INDEX on expensive function with (IsCachable)

Browse pgsql-php by date

  From Date Subject
Next Message Jesus Aneiros 2001-05-05 12:28:36 Re: psql with PHP question
Previous Message Andrew McMillan 2001-05-04 08:07:44 Re: [NOVICE] Re: psql with PHP question