I am trying to implement a query with multiple columns in a single where condition. But it making an sql error.
My original query is like this
SELECT id
FROM usertable
WHERE (user_addedon BETWEEN '2013-07-02 00:00:01' AND '2013-08-01 23:59:59')
OR (user_deletedon BETWEEN '2013-07-02 00:00:01' AND '2013-08-01 23:59:59')
OR (user_modified BETWEEN '2013-07-02 00:00:01' AND '2013-08-01 23:59:59')
What i am trying to do is to avoid the repetition of the BETWEEN
. From another SO post SQL multiple columns in IN clause i created a query query like this
SELECT id
FROM usertable
WHERE (user_addedon,user_deletedon,user_modifiedon) BETWEEN '2013-07-02 00:00:01' AND '2013-08-01 23:59:59'
But it is showing an error ERROR: input of anonymous composite types is not implemented
.
Is it because it cannot be implemented on PostgreSQL or is there any mistake in the query.
Also like to know if there are any other method to implement this?
I am using PostgreSQL 8.4