sql - Find points within a distance using MySQL -


I have a question about SSI queries in MySQL; I have a table with latitude and longitude columns; I have to get all the points near my geographical location using my distance (radius). I tried this question:

  select ID, (6371 * acos (cos (radians (78.3232)) * cos (radians (lat)) * cos (radians (lng) - Radians (65.3234)) Sin (Andean (78.3232)) Sin (radian (lat))) Distance as marker distance and Lt; 30 range range up to range 0, 20;  
  • Is this a good way to perform query queries?
  • How can I change this question if I understand that number, which has a square? Is Better to Use A Class?
  • I can not talk about the subject of performance in MySQL, but when in SQL Server Working on the same problem I used to build a box based on my distance compared to the results in section by just confirming for the where It should be within the late and long boundaries, at that point, this easy arithmetic comparison becomes possible, after which I have the results Number is reduced, then a i checks from to its original point.

    The complete issue of building the box is to reduce the number of records included in the first mathematical calculations.

    Here is my example from SQL Server.

    > announcement @Lat decimal (20, 13) = 35.7862, @long decimal (20, 13) = -80.3,0 9 5, @ radius decimal (7, 2) = 5, @date decimal (10, 2), @in earth_Radius INT = 6371000; SET @ distance = @ radius * 160 9444; Announcement @NorthLat Decimal (20, 13) = @Lat + Degree (@distance / @Earth_Radius), @ SouthLat Decimal (20, 13) = @Lat - Degree (@distance / @Earth_Radius), @ EastLong Decimal (20, 13 ) = @Long + Degree (@distance / @Earth_Radius/RadIans (@Lat)), @ WestLong Decimal (20, 13) = @Long - Degree (@distance / @Earth_Radius / Store Controller (RADIANS (@ Lat))); Choose * CPP from CustomerPosition (cp.Lat> = @SouthLat and cp.Lat & lt; = @NorthLat) and (cp.Long> = @WestLong and cp.Long & lt; = @ EastLong)

    The result of the original selection I store it in the temporary table and to see that the actual inside is defined by the distance


Comments