Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2syi-00055I-6W for pgsql-sql@arkaria.postgresql.org; Wed, 06 Feb 2013 00:35:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U2syh-00035d-9D for pgsql-sql@arkaria.postgresql.org; Wed, 06 Feb 2013 00:35:07 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2syg-00035U-Hi for pgsql-sql@postgresql.org; Wed, 06 Feb 2013 00:35:06 +0000 Received: from mail-pa0-f43.google.com ([209.85.220.43]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2sye-00058w-Ld for pgsql-sql@postgresql.org; Wed, 06 Feb 2013 00:35:05 +0000 Received: by mail-pa0-f43.google.com with SMTP id bh2so459239pad.16 for ; Tue, 05 Feb 2013 16:35:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:references:from:in-reply-to:mime-version:date:message-id :subject:to:cc:content-type; bh=IRxB8K3A7987yzWKwO4CvhBKCxchzblXqWfzt8WcChM=; b=0HceKE/qhYODTMz2xPRquPW9O/o1+gI0z8XGRUEisMw0crzglxasMLi8NgS9BUNuoe T9DRVS3YjskHFL+KXRm7WP9aQITHpgOabziWk7692Rzi1i13qEenIOsBzn9SHi6amF6f Lnr1nF25l7fwntEdaHtg2F5uTuZzlxYwgPezBztxHjD4HMakTOuKux7PGga0KfugnukA F8XEZEw5RXPlqL62jgor+5Sy8pz/P26lmP3NgNV12TGT0d1PXa82PEKLhaEqhmXp+UDa EWhLzZ+u3+yVQzDHkfIOw1iqxVEMhvO35WIng03BP1hSRRYybl+0M/KhG0xHY87ryS+m 78hA== X-Received: by 10.66.81.231 with SMTP id d7mr69330506pay.27.1360110903376; Tue, 05 Feb 2013 16:35:03 -0800 (PST) References: From: Anton Gavazuk In-Reply-To: Mime-Version: 1.0 (1.0) Date: Wed, 6 Feb 2013 00:35:03 +0000 Message-ID: <-1442825864597553886@unknownmsgid> Subject: Re: Setting a default value for a select statement without results To: JORGE MALDONADO Cc: "pgsql-sql@postgresql.org" Content-Type: text/plain; charset=ISO-8859-1 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Hi Jorge, Look on http://www.postgresql.org/docs/8.1/static/functions-conditional.html Thanks, Anton On Feb 6, 2013, at 0:23, JORGE MALDONADO wrote: > I have an UPDATE query with the following general structure: > > UPDATE table1 SET (SELECT field FROM table2 WHERE conditions ORDER BY order_field LIMIT 1) > > Is it possible to assign a default value in case no results are returned by the SELECT statement? > > Respectfully, > Jorge Maldonado -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql