MySQL/POINT:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
无编辑摘要
Kangkk​(留言 | 贡献)
小 文字替换 -“{{leftrightflex|”替换为“{{Double-columns|”
 
(未显示同一用户的2个中间版本)
第4行: 第4行:
创建测试表和字段。
创建测试表和字段。


{{leftrightflex|<syntaxhighlight lang="mysql">
{{Double-columns|<syntaxhighlight lang="mysql">
CREATE TABLE `test-location` (
CREATE TABLE `test-location` (
   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '序号',
   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '序号',
第14行: 第14行:
</pre>}}}}
</pre>}}}}


{{leftrightflex|<syntaxhighlight lang="mysql">
{{Double-columns|<syntaxhighlight lang="mysql">
INSERT INTO `test-location` (location, text) VALUES  
INSERT INTO `test-location` (location, text) VALUES  
   (ST_GeomFromText('POINT(100 200)'), '测试点1'),
   (ST_GeomFromText('POINT(100 200)'), '测试点1'),
第36行: 第36行:
);
);
  </syntaxhighlight>
  </syntaxhighlight>
使用 mysql{{Version|5.6.48}} 测试坐标点。
{{Double-columns|<syntaxhighlight lang="mysql">
select geomfromtext('Point(10.1234 20.5678)');
</syntaxhighlight>|{{consoleout|<pre>
AAAAAAEBAAAAHqfoSC4/JEA2qz5XW5E0QA==
</pre>}}}}
使用 mysql{{Version|8.0.28}} 测试坐标点。
{{Double-columns|<syntaxhighlight lang="mysql">
select st_geomfromtext('Point(10.1234 20.5678)');
</syntaxhighlight>|{{consoleout|<pre>
+-------------------------------------------+
| st_geomfromtext('Point(10.2045 34.2379)') |
+-------------------------------------------+
| POINT(10.2045 34.2379)                    |
+-------------------------------------------+
1 row in set (0.00 sec)
</pre>}}}}


== 函数 ==
== 函数 ==
第47行: 第66行:


== 查询数据 ==
== 查询数据 ==
{{leftrightflex|<syntaxhighlight lang="mysql">
{{Double-columns|<syntaxhighlight lang="mysql">
SELECT
SELECT
   id,
   id,
第66行: 第85行:


ST_AsText
ST_AsText
{{leftrightflex|<syntaxhighlight lang="mysql">
{{Double-columns|<syntaxhighlight lang="mysql">
SELECT id, ST_AsText(location), text FROM `test-location`;</syntaxhighlight>|{{consoleout|<pre>
SELECT id, ST_AsText(location), text FROM `test-location`;</syntaxhighlight>|{{consoleout|<pre>
+----+---------------------+------------+
+----+---------------------+------------+
第78行: 第97行:


== 更新数据 ==
== 更新数据 ==
{{leftrightflex|<syntaxhighlight lang="mysql">
{{Double-columns|<syntaxhighlight lang="mysql">
update `test-location` set location=st_GeomFromText('POINT(123 100)') where id =1;</syntaxhighlight>|{{consoleout|<pre>
update `test-location` set location=st_GeomFromText('POINT(123 100)') where id =1;</syntaxhighlight>|{{consoleout|<pre>
Query OK, 1 row affected (0.01 sec)
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
Rows matched: 1  Changed: 1  Warnings: 0
</pre>}}}}
</pre>}}}}