Oracle --gt; Postgres query(甲骨文 --Postgres 查询)
问题描述
我是一名试图将这样的查询转换为 Postgres 的 Oracle 人员.不是很了解所有语法等.希望有人能提供帮助吗?
Oracle 查询:<上一页>选择 c.code、c.recommendation、s.suggested、s.sugg_by、a.approved、a.app_byFROM(选择代码,推荐 FROM 推荐)c,(选择代码,建议,sugg_by FROM 建议) s,(选择代码,已批准,app_by FROM 建议)哪里 c.code = s.code(+)和 c.code = a.code(+);
非常感谢
可以尝试使用OUTER JOIN
选择 c.code、c.recommendation、s.suggested、s.sugg_by、a.approved、a.app_byFROM(选择代码,推荐 FROM 推荐)c左连接(选择代码,建议,sugg_by FROM 建议) s on c.code = s.codeLEFT JOIN(选择代码,已批准,app_by FROM 建议)a ON c.code = a.code
您似乎不需要使用子查询,因为您在子查询中没有做任何事情只选择原始列.可以直接查询表.
选择c.代码,c. 推荐,s.建议,s.sugg_by,a.批准,a.app_byFROM 建议 cc.code = s.code 上的 LEFT JOIN 建议LEFT JOIN 建议 a ON c.code = a.code
I'm an Oracle guy trying to convert a query like this to Postgres. Not really understanding all the syntax, etc. Was hoping someone can help?
Oracle Query:
SELECT c.code, c.recommendation, s.suggested, s.sugg_by, a.approved, a.app_by FROM (SELECT code, recommendation FROM recommendations) c, (SELECT code, suggested, sugg_by FROM suggestions) s, (SELECT code, approved, app_by FROM suggestions) a WHERE c.code = s.code(+) AND c.code = a.code(+);
Much appreciated
You can try to use OUTER JOIN
SELECT c.code, c.recommendation, s.suggested, s.sugg_by, a.approved, a.app_by
FROM (SELECT code, recommendation FROM recommendations) c
LEFT JOIN (SELECT code, suggested, sugg_by FROM suggestions) s on c.code = s.code
LEFT JOIN (SELECT code, approved, app_by FROM suggestions) a ON c.code = a.code
You seem like didn't need to use subquery, because you didn't do anything in the subquery only select original columns. you can query the table directly.
SELECT
c.code,
c.recommendation,
s.suggested,
s.sugg_by,
a.approved,
a.app_by
FROM recommendations c
LEFT JOIN suggestions s on c.code = s.code
LEFT JOIN suggestions a ON c.code = a.code
这篇关于甲骨文 -->Postgres 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:甲骨文 -->Postgres 查询
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- SQL 临时表问题 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 更改自动增量起始编号? 2021-01-01