ST_X()

TL;DR

Use ST_X() to obtain the first coordinate of a point.

Returns a point’s X coordinate.

Syntax

ST_X(point)

Arguments

Argument

Description

point

A POINT GEOMETRY or GEOMETRY32 value.

Return Value

Returns FLOAT64 for GEOMETRY and FLOAT32 for GEOMETRY32.

Usage Notes

  • The GEOMETRY32 overload returns a float32 value, as verified by geo_geometry32.sql.

Examples

DROP DATABASE IF EXISTS geo_x_demo;
CREATE DATABASE geo_x_demo;
USE geo_x_demo;

SELECT ST_X(ST_GeomFromText('POINT(3 4)')) AS x_coordinate;

DROP DATABASE geo_x_demo;

See Also