这个 SQL select 结构叫什么?

发布于 2024-09-24 11:05:35 字数 261 浏览 3 评论 0原文

下面粗体的 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 技术交流群。

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

发布评论

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

评论(4

萝莉病 2024-10-01 11:05:35

它是一个子查询。如果 bn 在外部查询中引用别名为 b 的表,那么它可以被称为 相关子查询

正如 guigui42 所指出的,它也是一个标量查询,因为它最多只返回一列和一行。事实上,您必须注意确保最多只返回一行,否则查询可能会在以后崩溃。通常可以通过使用 TOP 1 或等效方法来防止这种情况。

It is a subquery. If b.n refers to a table aliased as b 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 using TOP 1 or equivalent.

彻夜缠绵 2024-10-01 11:05:35

我会说“标量子查询

编辑:正如RedFilter所说,它也是一个相关子查询。

所以它是一个标量相关子查询

i would say "Scalar subquery"

EDIT : as RedFilter said, it is also a correlated subquery.

so it is a Scalar correlated subquery

蹲在坟头点根烟 2024-10-01 11:05:35

嵌套子查询。

...如果使用不当(这种情况很常见),性能也是出了名的差。

A nested sub-query.

...notoriously poor performers if mis-used (which is quite often) as well.

呢古 2024-10-01 11:05:35

这称为子选择

This is referred to as a sub-select.

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