date null

Started by ZioBuddaover 27 years ago3 messagesgeneral
Jump to latest
#1ZioBudda
michel@michel.enter.it
Hi, how can control in a "select" if a date is not null?
I have this table:
Table    = prestito
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                |
Length|
+----------------------------------+----------------------------------+-------+
| id_libro                         | varchar() not null               |
10 |
| id_utente                        | int4 not null                    |
4 |
| data_prestito                    | date                             |
4 |
| data_restituzione                | date                             |
4 |
| n_gg_prestito                    | int4 not null                    |
4 |
| notifica1                        | date                             |
4 |
| notifica2                        | date                             |
4 |
| notifica3                        | date                             |
4 |
+----------------------------------+----------------------------------+-------+

and I want to select only tuples in which notifica1 or notifica2 or
notifica3 are not null.

"Il divertimento e' giusto se la scimmia ci prende gusto"
--
Pluto Linux Press: http://ziobudda.enter.it/PLP
--
Morelli 'ZioBudda' Davide Michel - Member of Pluto Linux User Group
michel@enter.it - http://ziobudda.enter.it/
Linux Problem? Ask to linux@media.dsi.unimi.it
"/dev/ziobudda: access to /var/tmp/beer denied, use /var/adm/pineapple"

#2Taral
taral@mail.utexas.edu
In reply to: ZioBudda (#1)
RE: [GENERAL] date null

use IS NOT NULL:

SELECT * from prestito WHERE notifica1 IS NOT NULL OR notifica2 IS NOT NULL
OR notifica3 IS NOT NULL;

I seem to remember that the equality/inequality operators don't work on NULL
right now...

Taral

Show quoted text

-----Original Message-----
From: owner-pgsql-general@postgreSQL.org
[mailto:owner-pgsql-general@postgreSQL.org]On Behalf Of ZioBudda
Sent: Friday, October 23, 1998 7:47 AM
To: pgsql-general@postgreSQL.org
Subject: [GENERAL] date null

Hi, how can control in a "select" if a date is not null?
I have this table:
Table    = prestito
+----------------------------------+------------------------------
----+-------+
|              Field               |              Type                |
Length|
+----------------------------------+------------------------------
----+-------+
| id_libro                         | varchar() not null               |
10 |
| id_utente                        | int4 not null                    |
4 |
| data_prestito                    | date                             |
4 |
| data_restituzione                | date                             |
4 |
| n_gg_prestito                    | int4 not null                    |
4 |
| notifica1                        | date                             |
4 |
| notifica2                        | date                             |
4 |
| notifica3                        | date                             |
4 |
+----------------------------------+------------------------------
----+-------+

and I want to select only tuples in which notifica1 or notifica2 or
notifica3 are not null.

"Il divertimento e' giusto se la scimmia ci prende gusto"
--
Pluto Linux Press: http://ziobudda.enter.it/PLP
--
Morelli 'ZioBudda' Davide Michel - Member of Pluto Linux User Group
michel@enter.it - http://ziobudda.enter.it/
Linux Problem? Ask to linux@media.dsi.unimi.it
"/dev/ziobudda: access to /var/tmp/beer denied, use /var/adm/pineapple"

#3Ulf Mehlig
umehlig@uni-bremen.de
In reply to: ZioBudda (#1)
Re: [GENERAL] date null

Morelli 'ZioBudda' Davide Michel wrote:

Hi, how can control in a "select" if a date is not null? [...] I
want to select only tuples in which notifica1 or notifica2 or
notifica3 are not null.

did you try the following?

select *
from prestito
where notifica1 is not null or
notifica2 is not null or
notifica3 is not null

The type of the column shouldn't matter, should it? And watch out,
there is a difference between "something = 0"and "something is null"
with something beeing some numeric type (float, int etc.): The first
says that the value of "something" in that row is zero, the second,
that there isn't any value assigned to "something"in that row. With
value zero you can do calculations (some! ;-), with "null", you
can't.

Ulf

--
======================================================================
%%%%% Ulf Mehlig <ulf.mehlig@uni-bremen.de>
%%%%!%%% Projekt "MADAM" <umehlig@uni-bremen.de>
%%%% %!% %%%% ----------------------------------------------------
---| %%% MADAM: MAngrove | Center for Tropical Marine
||--%!% Dynamics | Biology
|| And | Fahrenheitstrasse 1
_ /||\_/\_ Management |
/ / \ \ ~~~~~~~~~~~~~~~~~ | 28359 Bremen/Germany
~~~~~~~~~~~~~~~~~~~~