SELECT v.objectId, v.ra, v.decl, s.objectId, s.ra, s.decl FROM Object v, Object s WHERE v.variability > 0.8 -- is a variable object AND s.extendedParam < 0.2 -- is a star AND v.objectId <> s.objectId AND spDist(v.ra, v.decl, s.ra, s.decl) < :distance AND (s.gMag-s.rMag < 0.0 OR s.rMag-s.iMag < 0.0 OR s.uMag-s.gMag < 1.0)