- #1
polystethylene
- 17
- 0
Hi all,
Trying to write an SQL query for the Sloan Digital Sky Survey that uses the NOT operator, and failing miserably.
Basically, I'm making photometric cuts in 4-d colour space, and I currently have a selection of inequalities that select enclosed regions of colour space.
However, I now want to NOT that triangle, and select everything but that triangle, whilst still specifying a simple 'must be bluer than:...' colour cut.
The problem is that I can't get the query to return the data with the missing triangle, it simply selects all blue items.
This is what I've tried so far:
(This is in the WHERE clause)
and (P.psfmag_u-P.psfmag_g) < 0.55
and NOT ( (P.psfmag_u-P.psfmag_g) >= (1.27*(P.psfmag_g- P.psfmag_r) + 0.25)
and (P.psfmag_u-P.psfmag_g) <= ((3.9*(P.psfmag_g-P.psfmag_r)) + 1.8)
and (P.psfmag_g- P.psfmag_r) > (1.6*(P.psfmag_r- P.psfmag_i) - 0.05)
and (P.psfmag_g- P.psfmag_r) < (1.28*(P.psfmag_r- P.psfmag_i) + 0.25)
and (P.psfmag_g- P.psfmag_r) < (-1.45*(P.psfmag_r- P.psfmag_i) + 0.2)
and (P.psfmag_r- P.psfmag_i) > (3.73*(P.psfmag_i- P.psfmag_z) - 0.24)
and (P.psfmag_r- P.psfmag_i) < (0.725*(P.psfmag_i- P.psfmag_z) + 0.18)
and (P.psfmag_r-P.psfmag_i) between -0.45 and 0.15
and (P.psfmag_i-P.psfmag_z) between -0.6 and 0.1)
Any help would be appreciated, I'm relatively new to SQL and I'm struggling to find a workaround.
The syntax checks out as being 'ok', but clearly the results aren't.
Trying to write an SQL query for the Sloan Digital Sky Survey that uses the NOT operator, and failing miserably.
Basically, I'm making photometric cuts in 4-d colour space, and I currently have a selection of inequalities that select enclosed regions of colour space.
However, I now want to NOT that triangle, and select everything but that triangle, whilst still specifying a simple 'must be bluer than:...' colour cut.
The problem is that I can't get the query to return the data with the missing triangle, it simply selects all blue items.
This is what I've tried so far:
(This is in the WHERE clause)
and (P.psfmag_u-P.psfmag_g) < 0.55
and NOT ( (P.psfmag_u-P.psfmag_g) >= (1.27*(P.psfmag_g- P.psfmag_r) + 0.25)
and (P.psfmag_u-P.psfmag_g) <= ((3.9*(P.psfmag_g-P.psfmag_r)) + 1.8)
and (P.psfmag_g- P.psfmag_r) > (1.6*(P.psfmag_r- P.psfmag_i) - 0.05)
and (P.psfmag_g- P.psfmag_r) < (1.28*(P.psfmag_r- P.psfmag_i) + 0.25)
and (P.psfmag_g- P.psfmag_r) < (-1.45*(P.psfmag_r- P.psfmag_i) + 0.2)
and (P.psfmag_r- P.psfmag_i) > (3.73*(P.psfmag_i- P.psfmag_z) - 0.24)
and (P.psfmag_r- P.psfmag_i) < (0.725*(P.psfmag_i- P.psfmag_z) + 0.18)
and (P.psfmag_r-P.psfmag_i) between -0.45 and 0.15
and (P.psfmag_i-P.psfmag_z) between -0.6 and 0.1)
Any help would be appreciated, I'm relatively new to SQL and I'm struggling to find a workaround.
The syntax checks out as being 'ok', but clearly the results aren't.