SQL ingress 语法

发布于 2024-10-12 17:32:14 字数 841 浏览 4 评论 0原文

不幸的是,我目前无法访问 Ingres 数据库,我只是想知道适用于标准 SQL 的内部联接语法是否也适用于 Ingres? 我还想知道内部联接的等价物。

例如,以下两条 SQL 语句是否有效?

声明 1:

SELECT a.Value1,
       a.Value2,
       b.Value3
FROM   Tabletype1 a, Tabletype2 b, Tabletype3 c
WHERE a.Value1 = b.Value4
AND   b.Tabletype3_Num = c.Tabletype3_Num
AND  p.Value5 = 'Randomvalue'
AND b.Value3 > 20
      AND (a.Tabletype1Format = 'Random' OR a.Tabletype1Format = 'Random1')

声明 2:

SELECT a.Value1,
       a.Value2,
       b.Value3
FROM   Tabletype1 a
       INNER JOIN Tabletype2 b
            ON  a.Value1 = b.Value4
       INNER JOIN Tabletype3 c
            ON  b.Tabletype3_Num = c.Tabletype3_Num
WHERE  c.Value5 = 'Randomvalue'
       AND b.Value3 > 20
       AND (a.Tabletype1Format = 'Random' OR a.Tabletype1Format = 'Random1')

Unfortunately, I don't have access to an Ingres database at the moment and I'm just wondering if the inner join syntax that applies in standard SQL also applies in Ingres?
I'm also wondering about the equivalent to inner join.

For instance, are the following two SQL statements valid?

Statement 1:

SELECT a.Value1,
       a.Value2,
       b.Value3
FROM   Tabletype1 a, Tabletype2 b, Tabletype3 c
WHERE a.Value1 = b.Value4
AND   b.Tabletype3_Num = c.Tabletype3_Num
AND  p.Value5 = 'Randomvalue'
AND b.Value3 > 20
      AND (a.Tabletype1Format = 'Random' OR a.Tabletype1Format = 'Random1')

Statement 2:

SELECT a.Value1,
       a.Value2,
       b.Value3
FROM   Tabletype1 a
       INNER JOIN Tabletype2 b
            ON  a.Value1 = b.Value4
       INNER JOIN Tabletype3 c
            ON  b.Tabletype3_Num = c.Tabletype3_Num
WHERE  c.Value5 = 'Randomvalue'
       AND b.Value3 > 20
       AND (a.Tabletype1Format = 'Random' OR a.Tabletype1Format = 'Random1')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

抚你发端 2024-10-19 17:32:14

为了回答OP实际提出的问题,Ingres绝对,当然,绝对完全支持两种形式的连接规范,并且在我费心查看的每种情况下,它都提出了完全相同的查询计划。

所以我的底线答案是做你认为适合你的情况的事情。它会工作得很好。

In response to the question the OP actually asked, Ingres absolutely, for sure, definitely does fully support BOTH forms of join specification, and in every case I have ever bothered to look at, it comes up with exactly the same query plan.

So my bottom line answer is do what you think is preferable in your situation. It will work fine.

懒猫 2024-10-19 17:32:14

两种形式在 Ingres 中都可以正常工作,尽管您会欣赏 SQL92 ANSI 语法对于

  1. 可读性
  2. 清晰度
  3. 更有利,以帮助查询优化器了解连接真正发生的位置

这个问题与 SQL 内连接语法

Both forms work fine in Ingres, although you would appreciate the SQL92 ANSI syntax is more preferable for

  1. readability
  2. clarity
  3. to help the query optimizer know where the join really happens

This question is very similar to SQL Inner Join syntax

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文