<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Basic problem is that I have a large table of GPS points and another input data set of GPS points.</p>
<p>For each input GPS point I want to find the closest 1 to it in the GPS table.</p>
<p>The GPS table can, handily, be constrained by 2 other relational tables that link to the GPS data</p>
<p>I've got the below query to work for me when searching the GPS table for 1 input point.</p>
<p>So I can put this into a scripted processing loop to get every input point by making many SQL queries.</p>
<p>However, I'm wondering if its possible to use an array of the input search points to do the complete search in 1 DB Query request.</p>
<p><br>
</p>
<p>Working SQL:</p>
<p><span>SELECT R.hash_id, N.gps_time FROM nav AS N, recording AS R, relation_recording_group AS G WHERE G.group_id = 52 AND G.recording_id = R.recording_id AND N.recording_id = R.recording_id AND R.formats < 10 AND R.status != 3 ORDER BY N.wgs_geom <-> ST_GeomFromText('POINT(LONGITUDE LATITUDE)',4326)
LIMIT 1;</span><br>
</p>
</div>
</body>
</html>