Pass column to ST_GeomFromText in MariaDB

Viewed 12

I would like to apply the st_geomfromtext function on a column called "location" with string values like this:

48.125116501359315 13.835729134104216

For PostgreSQL this works:

SELECT ST_GeomFromText('POINT('||location||')',4326) FROM test;

But when I try the same syntax for MariaDB I get the following error:

Illegal parameter data type boolean for operation 'st_geometryfromtext'

This seems to work (although I get a weird binary result:

SELECT ST_GeomFromText('POINT(48.125116501359315 13.835729134104216)',4326);

How can I make it work passing the column in MariaDB?

1 Answers

I just found out that in MariaDB concatenation by || is not activated by default. After using this:

SET sql_mode=(SELECT CONCAT(@@sql_mode,',PIPES_AS_CONCAT')); 

it is now working as desired.

Related