postgresql select as 问题

Im胡子 发布于 2013/12/31 12:16
阅读 1K+
收藏 0

@kenyon_君羊 你好,想跟你请教个问题:

在msql中可以实现这样的查询:

select id,name,3 as 'level','build' as 'nodeType', '' as 'hasOwner', housing_estate_id as pid , 'estate' as ptype

结果如下:

101	#1	3	build	""	71	estate
102	#2	3	build	""	71	estate
103	#3	3	build	""	71	estate
104	#4	3	build	""	71	estate
105	#5	3	build	""	71	estate
106	#6	3	build	""	71	estate

但在postgresql 中如果使用dblink语法就会报错

select t1.* from dblink('lz_base_dblink','select id,name,1 as "level","estate" as "nodeType" from housing_estate where is_deleted = 0') 
as t1 (id numeric(20,0),name varchar(50),level integer,nodeType varchar(50));

错误信息:

ERROR:  syntax error at or near "estate"
LINE 1: ...nk('lz_base_dblink','select id,name,1 as "level",'estate' as...
                                                             ^




加载中
0
kenyon_君羊
kenyon_君羊
换成E'\estate\' 或''estate''试一下
返回顶部
顶部