Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 34.6Mb
PDF (A4) - 34.6Mb
PDF (RPM) - 32.3Mb
HTML Download (TGZ) - 8.2Mb
HTML Download (Zip) - 8.2Mb
HTML Download (RPM) - 7.0Mb
Man Pages (TGZ) - 147.5Kb
Man Pages (Zip) - 208.8Kb
Info (Gzip) - 3.1Mb
Info (Zip) - 3.2Mb


Pre-General Availability Draft: 2017-12-16

12.15.7.2 Point Property Functions

A Point consists of X and Y coordinates, which may be obtained using the ST_X() and ST_Y() functions, respectively. These functions also permit an optional second argument that specifies an X or Y coordinate value, in which case the function result is the Point object from the first argument with the appropriate coordinate modified to be equal to the second argument.

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

  • If any argument is NULL, the return value is NULL.

  • If any geometry argument is a valid geometry but not a Point object, an ER_UNEXPECTED_GEOMETRY_TYPE error occurs.

  • If any geometry argument is not a syntactically well-formed geometry, an ER_GIS_INVALID_DATA error occurs.

  • If the coordinate value in the second argument is -inf, +inf, or NaN, an ER_DATA_OUT_OF_RANGE error occurs.

  • Otherwise, the return value is non-NULL.

These functions are available for obtaining point properties:

  • ST_X(p[, new_x_val])

    With a single argument representing a valid Point object p, ST_X() returns the X-coordinate value of p as a double-precision number.

    With the optional second argument representing a valid X-coordinate value, ST_X() returns a Point object with an X coordinate equal to the second argument.

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

    mysql> SELECT ST_X(Point(56.7, 53.34));
    +--------------------------+
    | ST_X(Point(56.7, 53.34)) |
    +--------------------------+
    |                     56.7 |
    +--------------------------+
    mysql> SELECT ST_AsText(ST_X(Point(56.7, 53.34), 10.5));
    +-------------------------------------------+
    | ST_AsText(ST_X(Point(56.7, 53.34), 10.5)) |
    +-------------------------------------------+
    | POINT(10.5 53.34)                         |
    +-------------------------------------------+
  • ST_Y(p[, new_y_val])

    With a single argument representing a valid Point object p, ST_Y() returns the Y-coordinate value of p as a double-precision number.

    With the optional second argument representing a valid Y-coordinate value, ST_Y() returns a Point object with an Y coordinate equal to the second argument.

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

    mysql> SELECT ST_Y(Point(56.7, 53.34));
    +--------------------------+
    | ST_Y(Point(56.7, 53.34)) |
    +--------------------------+
    |                    53.34 |
    +--------------------------+
    mysql> SELECT ST_AsText(ST_Y(Point(56.7, 53.34), 10.5));
    +-------------------------------------------+
    | ST_AsText(ST_Y(Point(56.7, 53.34), 10.5)) |
    +-------------------------------------------+
    | POINT(56.7 10.5)                          |
    +-------------------------------------------+

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