The DATA parameter is used to specify the data used to draw the map.
The form of DATA is “[geometry_column] from [table_name|sql_subquery]
using unique [unique_key] using srid=[spatial_reference_id]”. The
“using unique” and “using srid=” clauses are optional when drawing
features, but using them improves performance. If you want to make
MapServer query calls to a PostGIS layer, your DATA parameter must
include “using unique”. Omitting it will cause the query to fail.

This example shows specifying the unique key and srid in the DATA line:

CONNECTIONTYPEPOSTGISCONNECTION"dbname=yourdatabasename user=yourdbusername"DATA"the_geom from the_database using unique gid using srid=4326"

This example shows using a SQL subquery to perform a join inside the
database and map the result in MapServer. Note the “as subquery”
string in the statement – everything between “from” and “using” is
sent to the database for evaluation:

This example shows the use of the !BOX! substitution string to
over-ride the default inclusion of the map bounding box in the SQL. By
default the spatial box clause is appended to the SQL in the DATA
clause, but you can use !BOX! to insert it anywhere you like in the
statement. In general, you won’t need to use !BOX!, because the
PostgreSQL planner will generate the optimal plan from the generated
SQL, but in some cases (complex sub-queries) a better plan can be
generated by placing the !BOX! closer to the middle of the query: