Skip to main content
added 16 characters in body
Source Link
user1822
user1822

I am running postgres: 9.5.19

I have already point values as separate records in a table. I want to create a new record which represents a line geom derived from the two points above. I have lots of point records but I want to be able to select by id each point to link together.

I am trying this syntax:

insert into locations (geom,type,label,user) select st_makeline(a.geom,b.geom) as line from (select * from locations where id = 144) as a, (select * from locations where id = 145) as b, 'Link','test','ADMIN';

insert into locations (geom,type,label,user) 
select st_makeline(a.geom,b.geom) as line from (select * from locations where id = 144) as a, (select * from locations where id = 145) as b, 
'Link','test','ADMIN';

and get this error:

ERROR: syntax error at or near "'Link'" LINE 1: ...a, (select * from locations where id = 145) as b, 'Link','te...

ERROR: syntax error at or near "'Link'"
LINE 1: ...a, (select * from locations where id = 145) as b, 'Link','te...

Can someone point me to a working syntax?

I am running postgres: 9.5.19

I have already point values as separate records in a table. I want to create a new record which represents a line geom derived from the two points above. I have lots of point records but I want to be able to select by id each point to link together.

I am trying this syntax:

insert into locations (geom,type,label,user) select st_makeline(a.geom,b.geom) as line from (select * from locations where id = 144) as a, (select * from locations where id = 145) as b, 'Link','test','ADMIN';

and get this error:

ERROR: syntax error at or near "'Link'" LINE 1: ...a, (select * from locations where id = 145) as b, 'Link','te...

Can someone point me to a working syntax?

I am running postgres: 9.5.19

I have already point values as separate records in a table. I want to create a new record which represents a line geom derived from the two points above. I have lots of point records but I want to be able to select by id each point to link together.

I am trying this syntax:

insert into locations (geom,type,label,user) 
select st_makeline(a.geom,b.geom) as line from (select * from locations where id = 144) as a, (select * from locations where id = 145) as b, 
'Link','test','ADMIN';

and get this error:

ERROR: syntax error at or near "'Link'"
LINE 1: ...a, (select * from locations where id = 145) as b, 'Link','te...

Can someone point me to a working syntax?

Source Link

query two point values from a table then insert a new record after creating a line from the two points

I am running postgres: 9.5.19

I have already point values as separate records in a table. I want to create a new record which represents a line geom derived from the two points above. I have lots of point records but I want to be able to select by id each point to link together.

I am trying this syntax:

insert into locations (geom,type,label,user) select st_makeline(a.geom,b.geom) as line from (select * from locations where id = 144) as a, (select * from locations where id = 145) as b, 'Link','test','ADMIN';

and get this error:

ERROR: syntax error at or near "'Link'" LINE 1: ...a, (select * from locations where id = 145) as b, 'Link','te...

Can someone point me to a working syntax?