2016-02-18 91 views
1

我尝试创建与配位,看起来像这样的SQL数据库:SQL点错插入/选择

CREATE TABLE automaten_loc( 
id INT NOT NULL AUTO_INCREMENT, 
location POINT NOT NULL, 
primary key(ID)); 

我插入了一些数据:

INSERT INTO automaten_loc (location) 
VALUES (POINT(12.34567, 76.54321)); 

但选择*返回此:

enter image description here

我不太擅长SQL,我不知道什么是wro ng ...

你知道为什么吗? 谢谢:)

+0

执行该让我知道你的MySQL版本? –

回答

1

试试这个让X cordinate和y conrdinate

SELECT x(location),y(location) FROM test.automaten_loc; 

mysql> SELECT x(location),y(location) FROM test.automaten_loc; 
+-------------+-------------+ 
| x(location) | y(location) | 
+-------------+-------------+ 
| 12.34567 | 76.54321 | 
+-------------+-------------+ 

mysql> SELECT x(location),y(location),concat(x(location),', ',y(location)) FROM test.automaten_loc; 
+-------------+-------------+---------------------------------+ 
| x(location) | y(location) | concat(x(location),y(location)) | 
+-------------+-------------+---------------------------------+ 
| 12.34567 | 76.54321 | 12.34567, 76.54321    | 
+-------------+-------------+---------------------------------+ 
1 row in set (0.03 sec) 

我在系统

+0

嗯,这工作正常,谢谢:) – FlowX

1
SELECT ID, CONCAT(ST_X(location),',',ST_Y(location)) as loc FROM automaten_loc