在Postgres上插入查询时出错 [英] Error in insert query on postgres

查看:117
本文介绍了在Postgres上插入查询时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否可以在Postgres中编写如下的插入查询?

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



注意:(从expertmaintain中选择SELECT user_id,其中ST_Dwithin(ST_MakePoint(80.82,7.8),ST_MakePoint(added_lng,add_lat))返回文本



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

推荐答案

找到解决方案

< pre lang ="SQL">插入测试(col,col2)(SELECT``abc'',expertmainten的user_id保持在其中ST_Dwithin(ST_MakePoint(80.82,7.8),ST_MakePoint(add_lng,add_lat),0.2))); </pre>
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>


这篇关于在Postgres上插入查询时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆