Use ASTEXT with point value : ASTEXT « Geometric « SQL / MySQL






Use ASTEXT with point value

    
mysql>
mysql> CREATE TABLE cities (
    ->   id int(11) ,
    ->   pt point NOT NULL default '',
    ->   zip int(11) default NULL,
    ->   country varchar(10) default NULL,
    ->   state char(2) default NULL,
    ->   city varchar(100) default NULL,
    ->   district varchar(100) default NULL
    -> );
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>
mysql>
mysql> insert into cities (pt)values(GEOMFROMTEXT('POINT(7250 2750)'));
Query OK, 1 row affected (0.00 sec)

mysql>
mysql>
mysql>
mysql> SELECT id, ASTEXT(pt), zip, country AS cnt, state AS st, city, district
    -> FROM cities ORDER BY RAND() LIMIT 10;
+------+------------------+------+------+------+------+----------+
| id   | ASTEXT(pt)       | zip  | cnt  | st   | city | district |
+------+------------------+------+------+------+------+----------+
| NULL | POINT(7250 2750) | NULL | NULL | NULL | NULL | NULL     |
+------+------------------+------+------+------+------+----------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> drop table cities;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
  








Related examples in the same category

1.The ASTEXT function specifies the bounding box in WKT format
2.Querying geometric data is with the asText function