how to select custom value when exists otherwise select default

Поиск
Список
Период
Сортировка
От patrick
Тема how to select custom value when exists otherwise select default
Дата
Msg-id 421133db$0$6585$8fcfb975@news.wanadoo.fr
обсуждение исходный текст
Список pgsql-sql
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 ;-)


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Eugen Gass"
Дата:
Сообщение: Trigger
Следующее
От: Shridhar Daithankar
Дата:
Сообщение: Re: [GENERAL] How to view the list of tables?