问题标签 [nested-query]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1756 浏览

linq - 使用包含 bigint 的嵌套 LINQ 查询

这是我想要的 SQL(ClearinghouseKey是 a bigint):

内部查询是直截了当的,并在 LINQPad 中给出了正确的结果:

但是外部查询给出了错误:Type arguments from ...Contains..cannot be inferred from usage:

是因为 ClearinghouseKey 是一个 bigint 吗?还有其他方法可以编写此查询吗?

谢谢,珍妮

0 投票
2 回答
3025 浏览

sql - How to avoid nested SQL query in this case?

I have an SQL question, related to this and this question (but different). Basically I want to know how I can avoid a nested query.

Let's say I have a huge table of jobs (jobs) executed by a company in their history. These jobs are characterized by year, month, location and the code belonging to the tool used for the job. Additionally I have a table of tools (tools), translating tool codes to tool descriptions and further data about the tool. Now they want a website where they can select year, month, location and tool using a dropdown box, after which the matching jobs will be displayed. I want to fill the last dropdown with only the relevant tools matching the before selection of year, month and location, so I write the following nested query:

I resorted to this nested query because it was much faster than performing a JOIN on the complete database and selecting from that. It got my query time down a lot. But as I have recently read that MySQL nested queries should be avoided at all cost, I am wondering whether I am wrong in this approach. Should I rewrite my query differently? And how?

0 投票
4 回答
341 浏览

sql - SQL:帮助嵌套查询

这是我的架构:

供应商(sid:整数,sname:字符串,地址字符串)

部分(pid:整数, pname:字符串,颜色:字符串)

目录(sid:整数,pid:整数,成本:实数)

粗体表示主键。

我想写一个查询来查找所有供应每个零件的供应商。这是我已经提出的两个问题:

用命令式的术语来说,我想做的是这样的:

我怎样才能把它翻译成 MySQL?

0 投票
2 回答
287 浏览

sql - 同一张表,1字段对2字段查询

我有 2 个表:第 1 个保存员工(任何职位的员工),第 2 个保存带有 ID 号的经理员工关系。

我想写一个查询

我怎样才能做到这一点?

0 投票
2 回答
248 浏览

sql - 显示交付量最大的供应商名称(嵌套查询)?

我有一个S包含供应商(S,SNAME,CITY)的表,一个P包含产品(P,PNAME,COLOUR,WEIGHT,PRICE)的表和一个SP包含交付(S,P,QTY)的表,其中 S 和 P 是表的外键S和P。

我被要求做的是

“显示交付最多的供应商的名称(作为嵌套查询)。”

我该怎么做呢?

编辑:删除了我声称工作正常的代码。不是。

0 投票
1 回答
141 浏览

sql - 为什么我不能从我的查询中选择?

我有一个类似这样的查询(不,我的表和字段不是由这些名称调用的,但结构是相同的) -

它运行良好。但是,当我尝试从中进行选择时(我最终将尝试使用 group bys 等进行操作,但现在只是尝试了一个简单的选择),如下所示:

我得到错误:

我究竟做错了什么?

0 投票
2 回答
4915 浏览

sql - 何时对 postgres sql 使用嵌套查询?

有什么区别。。

真的有区别吗?

0 投票
1 回答
5189 浏览

mongodb - 在 MongoDb 中查询嵌套数组

我想通过嵌套数组中存在字符串来检索文档。例如,数据(表示句子的依赖解析)如下所示:

我找到的最接近的解决方案假定这['nn', ...]tuples列表的第二个位置:

有没有办法放松固定位置?元组(不是它们的内容)可以按任何顺序排列。

其次,能够检索具有 的文档真的很棒 ['nn', 'method', X],这意味着它们的依赖解析中的名词“方法”。

谢谢!

0 投票
5 回答
266 浏览

mysql - 有没有办法删除这种类型的 SQL SELECT 中的嵌套查询?

鉴于此表结构和示例数据(查询中不应使用 t3,此处仅显示 t1 和 t2 之间的关系):

您将如何构建满足以下条件的 SQL 查询:

当桌子更大时不会影响性能......?

0 投票
3 回答
110065 浏览

sharepoint - 具有多个字段的嵌套 AND 和 OR 的 CAML 查询

我正在研究概念验证代码,以根据提供给我正在编写的高度特定的搜索 Web 服务的关键字动态生成 CAML。我没有使用 SharePoint 提供的搜索 Web 服务来证明这一点。我已经为我想要实现的目标这样做了。从我所有的研究中,我找不到一个接近的例子来说明我想要实现的目标,即检查多个字段的多个值。是的,我已经在 SO 上寻找我的答案,包括这个:Need help on building CAML Query

话虽如此,如果可能的话,如何用 CAML 编写以下类似 SQL 的查询?