Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 33.4Mb
PDF (A4) - 33.4Mb
PDF (RPM) - 31.3Mb
HTML Download (TGZ) - 7.9Mb
HTML Download (Zip) - 8.0Mb
HTML Download (RPM) - 6.8Mb
Man Pages (TGZ) - 145.7Kb
Man Pages (Zip) - 206.7Kb
Info (Gzip) - 3.1Mb
Info (Zip) - 3.1Mb


Pre-General Availability Draft: 2017-09-22

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.

  • 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, or NULL if the argument is NULL. These conditions apply:

    If the optional second argument representing a valid X-coordinate value is given, ST_X() returns a Point object with an X coordinate equal to the second argument, or NULL if either argument is NULL. These conditions apply:

    • Error handling for the first argument is as for the single-argument syntax, as described previously.

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

    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, or NULL if the argument is NULL. These conditions apply:

    If the optional second argument representing a valid Y-coordinate value is given, ST_Y() returns a Point object with an Y coordinate equal to the second argument, or NULL if either argument is NULL. These conditions apply:

    • Error handling for the first argument is as for the single-argument syntax, as described previously.

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

    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.