ST_SymDifference()

Returns the symmetric difference of two polygonal geometries.

Syntax

ST_SymDifference(geom1, geom2)

Arguments

Argument

Description

geom1

First POLYGON or MULTIPOLYGON.

geom2

Second polygonal geometry from the same geometry family.

Return Value

Returns a polygonal geometry in the input geometry family.

Usage Notes

Examples

DROP DATABASE IF EXISTS geo_operation_demo;
CREATE DATABASE geo_operation_demo;
USE geo_operation_demo;

SELECT ST_Area(ST_SymDifference(ST_GeomFromText('POLYGON((0 0,4 0,4 4,0 4,0 0))'), ST_GeomFromText('POLYGON((2 2,6 2,6 6,2 6,2 2))'))) AS result_area;

DROP DATABASE geo_operation_demo;

See Also

Geo Functions Overview