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

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-novicepgsql-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

pgsql-novice by date

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

pgsql-php by date

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

pgsql-general by date

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

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