...
Add a new LAYER to the .MAP file and in the DATA entry add the following:
Code Block DATA "wkb_geometry from (select row_number() over () as ogc_fid, b.wkb_geometry, p.planref, p.name from demo_planning.blpu_polygons b inner join demo_planning.planning_applications p on st_intersects(b.wkb_geometry, p.wkb_geometry)) as foo using unique ogc_fid using srid=27700"
...