Search Postgresql Archives

exclusive OR possible within a where clause?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I'm guessing that this isn't possible, but you guys are pretty smart. :)
Short version, is there a way to implement an exclusive OR in a where clause?

table1
dt1(timestamp)
---------
3 mins
5 mins
7 mins

table2
dt2(timestamp),   timedifference(interval)
---------------  ----------------------
4 mins              1 min ( always positive )

I want to join these two tables, grabbing the row from table 1 that
has a time equal to table2's record + interval, but table 2 could
have values that fall smack dab in the middle of two table1 records,
and I don't want both.

select
  t1.dt1
from
  table1 t1,
  table2 t2
where
  t2.dt2 + t2.timedifference = t1.dt1
    XOR ;-)
  t2.dt2 - t2.timedifference = t1.dt1

It's not important which of the two closest times
I get, but would like to get just one without being
messy.

Thanks for any ideas.  Maybe there's a great function out there
that solves this?

Dave










--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux