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