这个 SQL select 结构叫什么?
下面粗体的 select 语句中 select 结构的术语是什么?
SELECT a.t1 as a,(SELECT bn as b FROM b WHERE bx = a.t1), c.t2 as c 来自 a,c WHERE ax = cx
我正在解释这可以在 oracle 中完成,但是当被问到它叫什么时,我想不出任何术语。有这个术语吗?或者只是选择一个选择结果?
编辑:扩展查询以使子查询使用清晰
What is the term for the select construct in the following select statement that is in bold?
SELECT a.t1 as a, (SELECT b.n as b FROM b WHERE b.x = a.t1), c.t2 as c
FROM a,c
WHERE a.x = c.x
I was explaining that this can be done in oracle but when asked what it was called, I couldn't think of any term. Is there a term for this? Or is it just selecting a select result?
EDIT: expanded query to make sub-query use clear
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它是一个子查询。如果
bn
在外部查询中引用别名为b
的表,那么它可以被称为 相关子查询。正如 guigui42 所指出的,它也是一个标量查询,因为它最多只返回一列和一行。事实上,您必须注意确保最多只返回一行,否则查询可能会在以后崩溃。通常可以通过使用
TOP 1
或等效方法来防止这种情况。It is a subquery. If
b.n
refers to a table aliased asb
in the outer query, then it could be referred to as a correlated subquery.As guigui42 notes, it is also a
scalar
query, since it is returning at most only one column and row. In fact, you must take care to ensure at most only one row is ever returned, or the query may crash at some later date. This is often guarded against by usingTOP 1
or equivalent.我会说“标量子查询”
编辑:正如RedFilter所说,它也是一个相关子查询。
所以它是一个标量相关子查询
i would say "Scalar subquery"
EDIT : as RedFilter said, it is also a correlated subquery.
so it is a Scalar correlated subquery
嵌套子查询。
...如果使用不当(这种情况很常见),性能也是出了名的差。
A nested sub-query.
...notoriously poor performers if mis-used (which is quite often) as well.
这称为
子选择
。This is referred to as a
sub-select
.