From: | "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | David Olbersen <dave(at)slickness(dot)org> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Don't want blank data |
Date: | 2001-01-25 22:54:44 |
Message-ID: | 200101252254.f0PMsjF29332@linda.lfix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
David Olbersen wrote:
>Greetings,
> Is there a way to have postgresql always return a value for each row
> requested? To be more clear, if I were using a Perl SQL hybrid I would wri
>te
> something like
>
> SELECT computer_ip or 'unset' FROM computers;
>
> So that if computers.computer_ip is NULL or '' I will get 'unset' back fro
>m
> the database. I hope this makes sense and somebody can point me in a good
> direction
SELECT COALESCE(computer_ip,'unset') AS computer_ip FROM computers;
COALESCE() returns the leftmost non-null value from its parameters.
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"My little children, let us not love in word, neither
in tongue; but in deed and in truth."
I John 3:18
From | Date | Subject | |
---|---|---|---|
Next Message | Glen and Rosanne Eustace | 2001-01-25 23:46:21 | Re: Problem with Dates |
Previous Message | Oliver Elphick | 2001-01-25 22:51:30 | Re: Is there anything like DESCRIBE? |