Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Is it possible to write an insert query like below in Postgres?
<br />
Insert into test (col,col2) (SELECT user_id from expertmaintain where ST_Dwithin(ST_MakePoint(80.82, 7.8),ST_MakePoint(added_lng, added_lat), 0.2),'abc');


I'm getting below error on this case.

ERROR:  syntax error at or near ","<br />
LINE 2: ...80.82, 7.8),ST_MakePoint(added_lng, added_lat), 0.2),'abc');

^


********** Error **********

ERROR: syntax error at or near ","<br />
SQL state: 42601


Note: (SELECT user_id from expertmaintain where ST_Dwithin(ST_MakePoint(80.82, 7.8),ST_MakePoint(added_lng, added_lat)) this returns a text
Posted
Updated 11-Sep-11 8:43am
v2

1 solution

Found the solution

<pre lang="SQL">Insert into test (col,col2) (SELECT 'abc', user_id from expertmaintain where ST_Dwithin(ST_MakePoint(80.82, 7.8),ST_MakePoint(added_lng, added_lat), 0.2));</pre>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900