In my script I pass Object ID as querystring parameter. like ?idobject=1962
Now first I have to access from the OBJECTS table the GeoLat and GeoLng columns
and I have to check again if there are other objects containing the same Geo Data
SELECT GeoLng, GeoLat
FROM OBJECTS
WHERE ID = 1962
from above query I have to read the GeoLng and GeoLat variables and have to write the second query as follows
SELECT O.ID
FROM OBJECTS O
WHERE GeoLng = '12.72812515' /* will be taken from above query */
AND GeoLat = '47.7794388' /* will be taken from above query */
AND EXISTS(
SELECT ID
FROM InfObjects
WHERE ID = O.ID
)
Can I write these 2 queries into a single query?
Thanks
Edit: Updated based on Rich’s comment.
What you need is a self-join.
Or even more efficiently, like this: