Re: [SQL] Setting a default value for a select statement without results

2013-02-06 Thread JORGE MALDONADO
This solution gave me the result I need, but it seems the process takes longer when COALESCE is added. What do you mean with the comment of "and you are happy with its performance" ? Does it have to do with performance? Regards, Jorge Maldonado On Tue, Feb 5, 2013 at 10:07 PM, Jasen Betts wrot

Re: [SQL] Setting a default value for a select statement without results

2013-02-05 Thread Jasen Betts
On 2013-02-06, JORGE MALDONADO wrote: > --f46d0401fb2fcb805e04d50354b1 > Content-Type: text/plain; charset=ISO-8859-1 > > 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) assuming you mean

Re: [SQL] Setting a default value for a select statement without results

2013-02-05 Thread Ian Lawrence Barwick
2013/2/6 JORGE MALDONADO : > 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? One opt

Re: [SQL] Setting a default value for a select statement without results

2013-02-05 Thread Anton Gavazuk
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

[SQL] Setting a default value for a select statement without results

2013-02-05 Thread JORGE MALDONADO
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