Advertisement

04.07.2008 at 10:33AM PDT, ID: 23302099
[x]
Attachment Details

simple query - select where empty timestamp field

Asked by kevindolan in PostgreSQL Database

Tags: pqsql

Hello,

I'm new to postgres and I've googled on this seemingly simple issue all morning...

FreeBSD 6.1
PostgreSQL 8.2.3
PHP 5.2.5

I want to query my table and return records (to script.php) that have an empty timestamp (with timezone) field.

please consider the following 2 example queries:

SELECT * FROM table WHERE timestamp = ''

SELECT * FROM table WHERE NOT timestamp

I know neither of these queries works but they give an idea of what I'm trying to accomplish.

I have a timestamp field set when the records are created but then I have another timestamp field which remains empty until the record gets processed. This way I know both when the record was created and when the record was updated/processed.

If I can't figure out how to do this I will need to change my table structure and add a boolean field to indicate whether or not a record has been processed. Considering I need to know when the record gets processed as well as if it has been processed in the first place; I thought this approach would be efficient.

The following query seems to get me what I want but when the year changes it will break...

SELECT * FROM table WHERE timestamp NOT LIKE '2008'

Thanks for any help!Start Free Trial
[+][-]04.07.2008 at 11:04AM PDT, ID: 21299155

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PostgreSQL Database
Tags: pqsql
Sign Up Now!
Solution Provided By: laneduncan
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.07.2008 at 11:33AM PDT, ID: 21299439

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628