Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 34.7Mb
PDF (A4) - 34.7Mb
PDF (RPM) - 32.6Mb
HTML Download (TGZ) - 8.2Mb
HTML Download (Zip) - 8.3Mb
HTML Download (RPM) - 7.1Mb
Man Pages (TGZ) - 129.9Kb
Man Pages (Zip) - 185.4Kb
Info (Gzip) - 3.2Mb
Info (Zip) - 3.2Mb


MySQL 8.0 Reference Manual  /  ...  /  GeometryCollection Property Functions

Pre-General Availability Draft: 2018-01-12

12.15.7.5 GeometryCollection Property Functions

These functions return properties of GeometryCollection values.

Unless otherwise specified, functions in this section handle their arguments as follows:

  • If any argument is NULL or any geometry argument is an empty geometry, the return value is NULL.

  • Otherwise, the return value is non-NULL.

These functions are available for obtaining geometry collection properties:

  • ST_GeometryN(gc, N)

    Returns the N-th geometry in the GeometryCollection value gc. Geometries are numbered beginning with 1.

    ST_GeometryN() handles its arguments as described in the introduction to this section.

    mysql> SET @gc = 'GeometryCollection(Point(1 1),LineString(2 2, 3 3))';
    mysql> SELECT ST_AsText(ST_GeometryN(ST_GeomFromText(@gc),1));
    +-------------------------------------------------+
    | ST_AsText(ST_GeometryN(ST_GeomFromText(@gc),1)) |
    +-------------------------------------------------+
    | POINT(1 1)                                      |
    +-------------------------------------------------+
  • ST_NumGeometries(gc)

    Returns the number of geometries in the GeometryCollection value gc.

    ST_NumGeometries() handles its arguments as described in the introduction to this section.

    mysql> SET @gc = 'GeometryCollection(Point(1 1),LineString(2 2, 3 3))';
    mysql> SELECT ST_NumGeometries(ST_GeomFromText(@gc));
    +----------------------------------------+
    | ST_NumGeometries(ST_GeomFromText(@gc)) |
    +----------------------------------------+
    |                                      2 |
    +----------------------------------------+

User Comments
Sign Up Login You must be logged in to post a comment.