首页 \ 问答 \ 迭代VS.(Iteration Vs. Enumeration)

迭代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
更新时间:2022-09-11 10:09

最满意答案

我只是将你的联接的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 ...
  • 你似乎有这两个独立的结构( -[意味着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 ...
  • 我只是将你的联接的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 ...
  • 笛卡尔联接通常表示您错过了某个地方的联接,这很糟糕,因为您的结果将不是您所期望的,并且查询可能会花费比预期更长的时间。 但是,情况并非总是如此。 假设你有两个相对较小的表格,你将每个表格过滤为一行。 这两个表都将连接到两个不同列上的更大表中,这两个列在同一个索引中。 在这种情况下,优化程序可能会决定将笛卡尔连接两个小结果集,因为结果数据集可以更有效地使用较大表上的索引。 简而言之,如果您在计划中看到笛卡尔联接,则应该仔细观察并尝试理解优化器选择该路由的原因。 这可能是因为你发现了一个尚未引起问题的错误,或者 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)