迭代VS.(Iteration Vs. Enumeration)
对于迭代,我知道有不同类型的迭代器,例如可用于访问数组中项目的Forward,Bidirectional,Random Access。
对于枚举,我只听说过可用于索引项目的枚举。 但有没有称为“枚举”或枚举器的术语? 如果是的话,迭代和枚举有什么区别?
For iteration, I know there are different types of iterators E.g. Forward, Bidirectional, Random Access that can be used to access items in an array.
For enumeration, I've only heard about enums that can be used to index items. But are there terms called 'enumeration' or enumerator? If so then, What's the difference between iteration and enumeration?
原文:https://stackoverflow.com/questions/7224259
最满意答案
我只是将你的联接的where子句移动到ON语句并进行了正确的连接,如果这不起作用我将设置一个sqlfiddle,看看这个sql的问题是什么
SELECT c.*, count(dm.id), u1.first_name, u1.last_name, u1.company, u1.picture, u2.first_name, u2.last_name, u2.company, u2.picture FROM "DirectConversation" c JOIN "DirectMessage" dm ON c.id = dm."id_DirectConversation" JOIN "Profile" u1 ON u1."id_User" = c."id_User1" JOIN "Profile" u2 ON u2."id_User" = c."id_User2" WHERE dm.viewed = 'f' AND dm.deleted = 'f' AND (c."id_User1" = $id OR c."id_User2" = $id) GROUP BY c.id, u1.id, u2.id;
编辑:为了安全起见,将OR子句分组
I just moved your where clauses for the joins to the ON statement and made proper joins, if this doesn't work I'll set up a sqlfiddle and see what the problem with this sql is
SELECT c.*, count(dm.id), u1.first_name, u1.last_name, u1.company, u1.picture, u2.first_name, u2.last_name, u2.company, u2.picture FROM "DirectConversation" c JOIN "DirectMessage" dm ON c.id = dm."id_DirectConversation" JOIN "Profile" u1 ON u1."id_User" = c."id_User1" JOIN "Profile" u2 ON u2."id_User" = c."id_User2" WHERE dm.viewed = 'f' AND dm.deleted = 'f' AND (c."id_User1" = $id OR c."id_User2" = $id) GROUP BY c.id, u1.id, u2.id;
Edit: grouped the OR clause just to be safe
相关问答
更多-
我会尝试这个 MATCH (c:TEST:LOC1) where c._text='P' with c MATCH (b:TEST_JOIN:LOC1) where b._out = c._in with b, c Match (a:Test:LOC1) WHERE a._out = b._in with a, c CREATE (a)-[r:TEST_JOIN]->(c) I would try this MATCH (c:TEST:LOC1) where c._text='P' with c MATC ...
-
在Postgres中左外层连接两层的结果产生笛卡尔积(Left outer join two levels deep in Postgres results in cartesian product)[2021-12-22]
你似乎有这两个独立的结构( -[意味着1-N关联]: events -[ profiles -[ donations events -[ event members 我将第二个包装到子查询中: SELECT events.name, member_count.the_member_count COUNT(DISTINCT event_members.id), SUM(donations.amount) FROM events LEFT OUTER JOIN profil ... -
您可以使用not exists从msg_messages为给定的participant_id选择最新的行 select mp.convo_id, mm.id, mp.prof_id, mp.prof_type, mm.message, mm.time_cre from msg_participants mp join msg_messages mm on mp.id = mm.participant_id where mp.prof_id = PROF_ID_HERE and mp.prof_type = ...
-
这不是一个正确的陈述。 我创建了HHH-11175 Jira问题,我将修复它。 我要把这个短语改为: 连接表继承多态查询可以使用多个JOINS,这可能会在获取大量实体时影响性能。 It's not a correct statement. I created the HHH-11175 Jira issue, and I'm going to fix it. I'm going to change that phrase to: The joined table inheritance polymorphi ...
-
与其他查询类型(HQL,Criteria,QueryOver)相比,NHibernate会自动丢弃Linq查询中的重复根实体。 但正如您在上一条评论中所说,您仍然从数据库中获取了那么多行,因此您的查询可能会很慢。 In contrast to other query types (HQL, Criteria, QueryOver) NHibernate automatically discards duplicate root entities in Linq queries. But as you sai ...
-
在开始创建笛卡尔积之前,您可以拥有一个FetchMode.Join。 如果您将其他人切换到FetchMode.Select或其他什么怎么办? You can have a single FetchMode.Join before you start creating cartesian products. What if you switch others to FetchMode.Select or something else?
-
为什么使用UDF导致笛卡尔积而不是完全外连接? 使用UDF需要笛卡尔积的原因非常简单。 由于您传递具有可能无限域和非确定性行为的任意函数,因此确定其值的唯一方法是传递参数并进行求值。 这意味着你只需要检查所有可能的配对。 另一方面简单的平等具有可预测的行为。 如果你使用t1.foo = t2.bar条件,你可以简单地用foo和bar分别调整t1和t2行以获得预期的结果。 而在关系代数中准确地说,外连接实际上是使用自然连接表示的。 除此之外的任何事情都只是一种优化。 任何方式强制笛卡尔产品的外连接 不是真的, ...
-
好吧,你总是将表加入到只有employee - 看起来Dep 也链接到Suc - 所以你需要第二个JOIN条件(不仅加入id_dep而且加入id_suc !)。 表Sec甚至需要三个 JOIN条件,因为它与Employee表共享三个id。 SELECT DISTINCT s.name as sucurs, d.name as depart, c.name as section, e.name AS emp FROM employee e INNER JOIN suc ...
-
Postgres Join Query有时会采用笛卡尔积(Postgres Join Query is SOMETIMES taking the cartesian product)[2023-12-15]
我只是将你的联接的where子句移动到ON语句并进行了正确的连接,如果这不起作用我将设置一个sqlfiddle,看看这个sql的问题是什么 SELECT c.*, count(dm.id), u1.first_name, u1.last_name, u1.company, u1.picture, u2.first_name, u2.last_name, u2.company, u2.picture FROM "DirectConversation" c JOIN "Dir ... -
合并加入CARTESIAN(Merge join CARTESIAN)[2023-01-03]
笛卡尔联接通常表示您错过了某个地方的联接,这很糟糕,因为您的结果将不是您所期望的,并且查询可能会花费比预期更长的时间。 但是,情况并非总是如此。 假设你有两个相对较小的表格,你将每个表格过滤为一行。 这两个表都将连接到两个不同列上的更大表中,这两个列在同一个索引中。 在这种情况下,优化程序可能会决定将笛卡尔连接两个小结果集,因为结果数据集可以更有效地使用较大表上的索引。 简而言之,如果您在计划中看到笛卡尔联接,则应该仔细观察并尝试理解优化器选择该路由的原因。 这可能是因为你发现了一个尚未引起问题的错误,或者 ...