From: Gyozo Papp <pgerzson@freestart.hu>
To: Jason <gee308@mediaone.net>
To: pgsql-php@postgresql.org
Cc: pgsql-novice@postgresql.org
Cc: pgsql-general@postgresql.org
Subject: Re: [PHP] psql with PHP question
Date: Thu, 3 May 2001 18:19:10 +0200
Message-ID: <011301c0d3ec$cd91c940$5145c5d5@jaguar> (raw)
References: <3AF1427C.B4E85A45@is3-design.com>
<3AF149C1.AEC30AA9@mediaone.net>
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.)
----- Original Message -----
From: "Jason" <gee308@mediaone.net>
To: <pgsql-php@postgresql.org>
Cc: <pgsql-novice@postgresql.org>; <pgsql-general@postgresql.org>
Sent: 2001. május 3. 14:06
Subject: [PHP] psql with PHP question
> Hi, I want to try and optimize my calls to postgreSQL from PHP. If
> I only need one field from a select statement, what should I use? I am
> currently using:
> $q = pg_Exec("SELECT id FROM article WHERE id=(SELECT MAX(id)
> FROM article)");
> $maxid = pg_fetch_array($q, 0);
> echo "The highest id is ". $maxid[0];
> What can I use besides an array to get a single value? In general, using
> a single variable always saves more memory than using an array? Thank
> you.
> Jason
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: pgerzson@freestart.hu, gee308@mediaone.net, pgsql-novice@postgresql.org, pgsql-general@postgresql.org
Subject: Re: [PHP] psql with PHP question
In-Reply-To: <011301c0d3ec$cd91c940$5145c5d5@jaguar>
References: <3AF1427C.B4E85A45@is3-design.com> <3AF149C1.AEC30AA9@mediaone.net> <011301c0d3ec$cd91c940$5145c5d5@jaguar>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox