Q:

I don't get the results I want from my query

I have two tables called 'District' and 'SensorData'. From these two tables I want to know which points from table 'SensorData' are inside 'District' polygons. 
I have written this query to get the results I want: 
SELECT combined_sensor_data.point_geom, district.geom_pol
FROM combined_sensor_data, district
WHERE ST_Within(district.geom_pol, combined_sensor_data.point_geom);

but unfortunately I get no point in any district. Which I know for sure that this is a wrong result. So I am assuming I have a mistake in my query. Therefore, I am asking what could be wrong in my query?

A:

You could try changing arguments order:
SELECT combined_sensor_data.point_geom, district.geom_pol
FROM combined_sensor_data
JOIN district
  ON ST_Within(combined_sensor_data.point_geom, district.geom_pol);

