Y
Y
yeezussniper2021-03-15 12:33:12
MySQL
yeezussniper, 2021-03-15 12:33:12

How to insert value into LINESTRING?

I don't understand what the problem is. I create a function that has a variable with LINESTRING. I need to add value to it. As I understand it is just a string. But when I add value, nothing works. What is the correct way to add variables in such situations?

SET @g1 = 100;

SET @test = '100';

SET @g2 = 'LINESTRING(0 ' + @test + ', 100000 100)';

SELECT @g2;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Smirnov, 2021-03-21
@yeezussniper

In MySQL, strings are concatenated with the CONCAT() function

SET @g1 = 100;
SET @g2 = CONCAT('SELECT LINESTRING(0 ', @g1, ', 100000 100)');
SELECT @g2;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question