Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 返回一套记录_Postgresql - Fatal编程技术网

Postgresql 返回一套记录

Postgresql 返回一套记录,postgresql,Postgresql,我有一个表,存储分为字段的记录,即如果我有如下记录 { "name": "John Doe" "gender": "male" } [ { "id": "1", "col": "name", "value": "John Doe" }, { "id": "1", "col": "gender", "value": "male" } ] 然后该记录以2行的形式存储在表中,如下所示 { "name": "John Doe" "gender": "m

我有一个表,存储分为字段的记录,即如果我有如下记录

{
    "name": "John Doe"
    "gender": "male"
}
[
    { "id": "1", "col": "name", "value": "John Doe" },
    { "id": "1", "col": "gender", "value": "male" }
]
然后该记录以2行的形式存储在表中,如下所示

{
    "name": "John Doe"
    "gender": "male"
}
[
    { "id": "1", "col": "name", "value": "John Doe" },
    { "id": "1", "col": "gender", "value": "male" }
]
如果我想编写一个postgresql函数,将记录返回到原始表单(一行表单中的所有属性,而不是一个属性一行表单),我该怎么做


(表设计是为了数据仓库的目的而做的实验)

如果我没弄错的话,你可以这样写

select a.value, b.value
from table1 a 
inner join table1 b on a.id = b.id and a.orderNum < b.orderNum 
选择a.值,b.值
来自表1 a
a.id=b.id和a.orderNum
为了简单起见,可以引入字段orderNum

p、 我没有安装Postgress,所以您可能会修复我的查询