MySQL/POINT:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
小 Kangkk移动页面Mysql/point至MySQL/POINT,不留重定向
Kangkk​(留言 | 贡献)
小 文字替换 -“{{leftrightflex|”替换为“{{Double-columns|”
 
第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'),
第38行: 第38行:


使用 mysql{{Version|5.6.48}} 测试坐标点。
使用 mysql{{Version|5.6.48}} 测试坐标点。
{{leftrightflex|<syntaxhighlight lang="mysql">
{{Double-columns|<syntaxhighlight lang="mysql">
select geomfromtext('Point(10.1234 20.5678)');
select geomfromtext('Point(10.1234 20.5678)');
</syntaxhighlight>|{{consoleout|<pre>
</syntaxhighlight>|{{consoleout|<pre>
第45行: 第45行:


使用 mysql{{Version|8.0.28}} 测试坐标点。
使用 mysql{{Version|8.0.28}} 测试坐标点。
{{leftrightflex|<syntaxhighlight lang="mysql">
{{Double-columns|<syntaxhighlight lang="mysql">
select st_geomfromtext('Point(10.1234 20.5678)');
select st_geomfromtext('Point(10.1234 20.5678)');
</syntaxhighlight>|{{consoleout|<pre>
</syntaxhighlight>|{{consoleout|<pre>
第66行: 第66行:


== 查询数据 ==
== 查询数据 ==
{{leftrightflex|<syntaxhighlight lang="mysql">
{{Double-columns|<syntaxhighlight lang="mysql">
SELECT
SELECT
   id,
   id,
第85行: 第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>
+----+---------------------+------------+
+----+---------------------+------------+
第97行: 第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>}}}}