Empty Output? How Do I Determine the Character?

Started by Hunter Hillegasover 22 years ago4 messagesgeneral
Jump to latest
#1Hunter Hillegas
lists@lastonepicked.com

I cannot determine what character is stored in a varchar...

For instance:
thedonnaholics=# select state from mailing_list where rec_num = 7;
state
-------

(1 row)

If I then execute:
thedonnaholics=# select count(*) from mailing_list where state = '';
count
-------
0
(1 row)

So, what is in that first row?

This also returns 0:
thedonnaholics=# select count(*) from mailing_list where state = ' ';
count
-------
0
(1 row)

Any ideas? I'd like to select all rows that contain whatever that first one
contains...

Hunter

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hunter Hillegas (#1)
Re: Empty Output? How Do I Determine the Character?

Hunter Hillegas <lists@lastonepicked.com> writes:

I cannot determine what character is stored in a varchar...
For instance:
thedonnaholics=# select state from mailing_list where rec_num = 7;
state
-------

(1 row)

I'd say it's either NULL or between one and five space characters.
To find out, try something like

select '>' || state || '<' from mailing_list where rec_num = 7;

regards, tom lane

#3Hunter Hillegas
lists@lastonepicked.com
In reply to: Tom Lane (#2)
Re: Empty Output? How Do I Determine the Character?

Ok... I don't think that it is null:
thedonnaholics=# select count(*) from mailing_list where state = null;
count
-------
0
(1 row)

I ran the query you suggested but I don't know what it means:
thedonnaholics=# select '>' || state || '<' from mailing_list where rec_num
= 7;
?column?
----------

(1 row)

Any insight appreciated.

Thanks,
Hunter

Show quoted text

From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Fri, 08 Aug 2003 19:03:24 -0400
To: Hunter Hillegas <lists@lastonepicked.com>
Cc: PostgreSQL <pgsql-general@postgresql.org>
Subject: Re: [GENERAL] Empty Output? How Do I Determine the Character?

Hunter Hillegas <lists@lastonepicked.com> writes:

I cannot determine what character is stored in a varchar...
For instance:
thedonnaholics=# select state from mailing_list where rec_num = 7;
state
-------

(1 row)

I'd say it's either NULL or between one and five space characters.
To find out, try something like

select '>' || state || '<' from mailing_list where rec_num = 7;

regards, tom lane

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hunter Hillegas (#3)
Re: Empty Output? How Do I Determine the Character?

Hunter Hillegas <lists@lastonepicked.com> writes:

I ran the query you suggested but I don't know what it means:
thedonnaholics=# select '>' || state || '<' from mailing_list where rec_num
= 7;
?column?
----------

(1 row)

It means it's NULL. (Hint: foo = NULL is not the same as foo IS NULL.)

regards, tom lane