patternsqlMajor
PostgreSQL selecting empty fields of integer type
Viewed 0 times
postgresqlfieldsemptytypeselectinginteger
Problem
I have a table and I need to select all the rows with an empty value for the
However this doesn't work,
Trying
If anyone has any suggestions on how to sort this, I would be very grateful.
fk_fc_id field (as a prelude to deleting them),Column | Type | Modifiers
---------------+-----------------------------+------------------------------------------------------------
di_timestamp | timestamp without time zone |
di_item_value | character varying(10) |
fk_fc_id | integer |
di_id | integer | not null default nextval('data_item_di_id_seq1'::regclass)However this doesn't work,
# select fk_fc_id,di_timestamp,di_item_value from data_item where fk_fc_id="";
ERROR: zero-length delimited identifier at or near """"
LINE 1: ...di_timestamp,di_item_value from data_item where fk_fc_id="";
^Trying
Null doesn't work either. If anyone has any suggestions on how to sort this, I would be very grateful.
Solution
This is not really database administration related, nor is it really about PostgreSQL, but as @foibs answered, you should have a look at IS NULL:
SELECT fk_fc_id,
di_timestamp,
di_item_value
FROM data_item
WHERE fk_fc_id IS NULLCode Snippets
SELECT fk_fc_id,
di_timestamp,
di_item_value
FROM data_item
WHERE fk_fc_id IS NULLContext
StackExchange Database Administrators Q#54343, answer score: 29
Revisions (0)
No revisions yet.