SELECT node.* FROM gps_nodes as node, (SELECT count(*) as n, g.gid FROM linestrings as l , gps_nodes as g WHERE ST_equals(l.geom_line, ST_GeomFromText('LINESTRING(g.EASTING g.NORTHING, -1.911782 53.26144)') GROUB BY g.gid) as c WHERE node.gid = c.gid AND c.n = 0 (i didnt test, may not contains necessary amount of ) ) query creates "table" which has n and gid columns ( n is count and gid is unique id in gps_table) , assigns alias c for it and then joins table with gps_nodes table ( alias node) and limits rows to where n = 0 change gid to match your gps_nodes table. note table alias use