声明:本PostgreSQl实用指南系列为刘兴(http://deepfuture.iteye.com/)原创,未经笔者授权,任何人和机构不能转载
子查询的结果中构造一个数组
D:\pgsql>psql mydb
psql (8.4.2)
Type "help" for help.
mydb=#
mydb=# select * from student,citys where student.city=citys.id
mydb-# ;
name | age | city | sex | name | id
------------+-----+------+-------+------+----
艾丝凡 | 18 | 3 | | 上海 | 3
萨芬 | 19 | 3 | | 上海 | 3
未来 | 20 | 2 | man | 湛江 | 2
干哈 | 18 | 2 | man | 湛江 | 2
deepfuture | 20 | 1 | woman | 长沙 | 1
张三 | 21 | 1 | woman | 长沙 | 1
王五 | 25 | 3 | man | 上海 | 3
李白 | 23 | 2 | man | 湛江 | 2
李国 | 24 | 1 | woman | 长沙 | 1
(9 rows)
mydb=# select citys.name as 城市,array(select name from student where student.ci
ty=citys.id) as 学生 from citys;
城市 | 学生
------+------------------------
长沙 | {deepfuture,张三,李国}
湛江 | {未来,干哈,李白}
上海 | {艾丝凡,萨芬,王五}
(3 rows)
mydb=# select * from student;
name | age | city | sex
------------+-----+------+-------
艾丝凡 | 18 | 3 |
萨芬 | 19 | 3 |
未来 | 20 | 2 | man
干哈 | 18 | 2 | man
deepfuture | 20 | 1 | woman
张三 | 21 | 1 | woman
王五 | 25 | 3 | man
李白 | 23 | 2 | man
李国 | 24 | 1 | woman
(9 rows)
mydb=# select * from citys;
name | id
------+----
长沙 | 1
湛江 | 2
上海 | 3
(3 rows)
mydb=#
分享到:
相关推荐
标题中提到的"postgresql-42.2.2.jar"和"postgresql-9.2-1003.jdbc4.jar"是与PostgreSQL相关的Java档案(JAR)文件,它们在Java应用程序中用于与PostgreSQL数据库进行交互。 首先,"postgresql-42.2.2.jar"是...
赠送jar包:postgresql-42.2.6.jar; 赠送原API文档:postgresql-42.2.6-javadoc.jar; 赠送源代码:postgresql-42.2.6-sources.jar; 赠送Maven依赖信息文件:postgresql-42.2.6.pom; 包含翻译后的API文档:...
postgresql-13.2-1-windows-x64.rar postgresql-13.2-1-windows-x64.rar postgresql-13.2-1-windows-x64.rar postgresql-13.2-1-windows-x64.rar postgresql-13.2-1-windows-x64.rar
赠送jar包:postgresql-42.2.5.jar; 赠送原API文档:postgresql-42.2.5-javadoc.jar; 赠送源代码:postgresql-42.2.5-sources.jar; 赠送Maven依赖信息文件:postgresql-42.2.5.pom; 包含翻译后的API文档:...
postgresql-42.5.0.jar在许多Java框架如Hibernate和Spring等中使用,并很受开发人员的欢迎。它是经过定期更新和改进的,以确保其与最新版本的PostgreSQL数据库兼容,同时提供了丰富的API和文档,方便程序员进行开发...
赠送jar包:postgresql-42.3.3.jar; 赠送原API文档:postgresql-42.3.3-javadoc.jar; 赠送源代码:postgresql-42.3.3-sources.jar; 赠送Maven依赖信息文件:postgresql-42.3.3.pom; 包含翻译后的API文档:...
赠送jar包:postgresql-42.2.2.jar; 赠送原API文档:postgresql-42.2.2-javadoc.jar; 赠送源代码:postgresql-42.2.2-sources.jar; 赠送Maven依赖信息文件:postgresql-42.2.2.pom; 包含翻译后的API文档:...
PostgreSQL(postgresql-13.5-1-windows-x64.exe)适用于Windows x86-64 PostgreSQL是一种特性非常齐全的自由软件的对象-关系型数据库管理系统(ORDBMS),是以加州大学计算机系开发的POSTGRES,4.2版本为基础的...
`postgresql-42.3.3.jar` 提供了对PostgreSQL的JDBC驱动实现,使得Java开发者可以利用JDBC API来执行诸如建立数据库连接、执行SQL查询、处理结果集等任务。 在使用`postgresql-42.3.3.jar`之前,你需要将其添加到你...
PostgreSQL(postgresql-14.2-2-windows-x64.exe),适用于Windows系统:PostgreSQL是一种特性非常齐全的自由软件的对象-关系型数据库管理系统(ORDBMS),是以加州大学计算机系开发的POSTGRES,4.2版本为基础的对象...
postgresql-12.18-1-windows-x64.exe
此“postgresql-9.1.3-1-windows-x64”压缩包是专为64位Windows系统设计的PostgreSQL 9.1.3版本。 PostgreSQL 9.1.3是该数据库系统的其中一个稳定版本,发布于2012年,包含了多项增强和修复。在这一版本中,开发者...
首先,"PostgreSQL-9.2.4-1-windows-x64.rar" 是一个压缩文件,包含了PostgreSQL 9.2.4在64位Windows操作系统上的安装程序。解压这个RAR文件后,我们会得到"PostgreSQL-9.2.4-1-windows-x64.exe",这是用于安装...
postgresql-42.2.5 JBDC驱动,这个驱动可以用于Pycharm连接到PostgreSQL,具体操作方法可以阅读《Pycharm 配置PostgreSQL-利用自带database》网址:...
此压缩包"postgresql-10.16-2-windows-x64.zip"包含了PostgreSQL 10.16的64位Windows版本,适合在Windows操作系统上搭建数据库服务。 PostgreSQL 10.16是该数据库系统的一个稳定版本,它在前一版本的基础上进行了多...
赠送jar包:postgresql-42.3.1.jar; 赠送原API文档:postgresql-42.3.1-javadoc.jar; 赠送源代码:postgresql-42.3.1-sources.jar; 赠送Maven依赖信息文件:postgresql-42.3.1.pom; 包含翻译后的API文档:...
postgresql-10.21-1-windows-x64.exe安装包
postgresql-10.23-1的windows32版本
postgresql-9.2.24-1.el7_5.x86_64,postgresql-libs-9.2.24-1.el7_5.x86_64.rpm,postgresql-devel-9.2.24-1.el7_5.x86_64.rpm
PostgreSQL(postgresql-13.5.tar.gz) PostgreSQL是一种特性非常齐全的自由软件的对象-关系型数据库管理系统(ORDBMS),是以加州大学计算机系开发的POSTGRES,4.2版本为基础的对象关系型数据库管理系统。POSTGRES...