SQL ingress 语法
不幸的是,我目前无法访问 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了回答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.
两种形式在 Ingres 中都可以正常工作,尽管您会欣赏 SQL92 ANSI 语法对于
这个问题与 SQL 内连接语法
Both forms work fine in Ingres, although you would appreciate the SQL92 ANSI syntax is more preferable for
This question is very similar to SQL Inner Join syntax