There is a table with objects, they have coordinates position_x and position_y. You need to know which of these records fall into a polygon. Try so

SELECT * FROM `flats` WHERE ST_contains(ST_GeomFromText('POLYGON((54.1 26, 54.1 29, 54.3 29, 54.3 26, 54.1 26))'),ST_GeomFromText('POINT((position_x,position_y))')) 

returns nothing, although there are objects, checked

    1 answer 1

    In order to get a point from the coordinates in the table, you do not need to transpose the rows, the Point () function simply takes arguments

     SELECT * FROM `flats` WHERE ST_contains(ST_GeomFromText('POLYGON(54.1 26, 54.1 29, 54.3 29, 54.3 26, 54.1 26)'), Point(position_x, position_y)) 
    • Thank you for what you need. I myself thought that there was an error in the formation of a point, but I did not find something anywhere else a normal example - VK