From: | "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu> |
---|---|
To: | Ed Loehr <eloehr(at)austin(dot)rr(dot)com> |
Cc: | Joseph Shraibman <jks(at)p1(dot)selectacast(dot)net>, "pgsql-interfaces(at)postgreSQL(dot)org" <pgsql-interfaces(at)postgreSQL(dot)org> |
Subject: | Re: [INTERFACES] selectecting not null varchars. |
Date: | 2000-02-24 20:40:06 |
Message-ID: | 20000224144006.B11186@rice.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
On Thu, Feb 24, 2000 at 02:04:40PM -0600, Ed Loehr wrote:
> Joseph Shraibman wrote:
> >
> > select * from directory where h != null ;
> > ... gets you this:
> > ERROR: parser: parse error at or near ";"
>
> Postgresql's SQL "not equal" operator is "<>"...Try this:
>
> select * from directory where h <> null;
Which is still throw an error. and the SQL standard way to test for
NOT NULL is:
SELECT * FROM directory WHERE h IS NOT NULL;
Here's an example:
test=> \d test
Table = test
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| date | int4 default now ( ) | 4 |
| t | text | var |
+----------------------------------+----------------------------------+-------+
test=> insert into test (t) values ('');
INSERT 869922 1
test=> select * from test;
date|t
---------+-----
949357548|two
949357551|later
951424534|
-1|one
951424715|
(5 rows)
test=> select * from test where t is not null;
date|t
---------+-----
949357548|two
949357551|later
-1|one
951424715|
(4 rows)
test=>
test=> select * from test where length(t) >0;
ERROR: Null input to textlen
test=> select * from test where t is not null and length(t) >0;
date|t
---------+-----
949357548|two
949357551|later
-1|one
(3 rows)
test=>
Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
From | Date | Subject | |
---|---|---|---|
Next Message | Joseph Shraibman | 2000-02-24 21:46:47 | Re: [INTERFACES] selectecting not null varchars. |
Previous Message | Ed Loehr | 2000-02-24 20:04:40 | Re: [INTERFACES] selectecting not null varchars. |