简体   繁体   中英

How can I use MySQL variable with POINT

I am trying to use a MySQL variable together with POINT like this (simplified):

SET @lat=145.033667; SET @long=-37.932000; INSERT INTO Location(position) values (GeomFromText(‘POINT(@lat @long)'));

This works fine:

SELECT 'POINT(145.033667 -37.932000)';

As does this:

SELECT GeomFromText('POINT(145.033667 -37.932000)');

Is there anyone who know how I can make this work?

I think you have a syntax error:

SET @lat=145.033667; 
SET @long=-37.932000; 
INSERT INTO Location(position) 
values (GeomFromText('POINT(@lat @long)'));  
                    ^^^ Here you need '

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM