SQL statement for Postgres:
SELECT
*
FROM
users
WHERE
ST_DWithin (
users.location,
ST_SetSRID (ST_MakePoint (-71.0596, 42.3601), 4326),
1000
);
Explanation:
SELECT
statement is used to retrieve data from the users
table.ST_DWithin
function is used to find users whose location is within a certain distance from a given point.users.location
column represents the location of each user in the table.ST_SetSRID
function is used to set the spatial reference system identifier (SRID) for the given point.ST_MakePoint
function is used to create a point with the specified latitude and longitude coordinates.-71.0596
and 42.3601
values represent the longitude and latitude coordinates of downtown Boston, respectively.4326
value is the SRID for the WGS 84 coordinate system, which is commonly used for representing latitudes and longitudes.1000
value represents the distance in meters within which we want to find users.