pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: patrick <none@nowhere.fr>
To: pgsql-sql@postgresql.org
Subject: how to select custom value when exists otherwise select default
Date: Tue, 15 Feb 2005 00:26:33 +0100
Message-ID: <421133db$0$6585$8fcfb975@news.wanadoo.fr> (raw)


I use a select like this:
SELECT sometables
WHERE field0='a' or field0='b' or field0='c'
and field4='m' or field4='n'
ORDER BY field0;

m.field4 is default value
n.field4 is custom value

I want only n(custom) if it exists ortherwise I want m(default)
but I do not want both!

I mean I have this result:
table{
field0 {a,a,b,c}
field1 {d,d,e,f}
field2 {g,g,h,i}
field3 {j,j,k,l}
field4 {m,n,m,m}
}
a.filed0 has 2 results, one for m(default) and one for n(optionnal)
b and c have no custom value so field4 is set to m for them

and I want this result:
table{
field0 {a,b,c}
field1 {d,e,f}
field2 {g,h,i}
field3 {j,k,l}
field4 {n,m,m}
}

of course I'm looking for only one request to do that, and I'd rather a
lighter one ;-)



Message-ID: <421133db$0$6585$8fcfb975@news.wanadoo.fr>
Permalink:  ../421133db$0$6585$8fcfb975@news.wanadoo.fr/
Also on:    postgresql.org/message-id/421133db$0$6585$8fcfb975@news.wanadoo.fr

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: none@nowhere.fr
  Subject: Re: how to select custom value when exists otherwise select default
  In-Reply-To: <421133db$0$6585$8fcfb975@news.wanadoo.fr>

* 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