首页 \ 问答 \ 'on子句'中的未知列'userc.u_id'(Unknown column 'userc.u_id' in 'on clause')

'on子句'中的未知列'userc.u_id'(Unknown column 'userc.u_id' in 'on clause')

我正在使用Codeigniter,我正在尝试使用所有已保存的自定义字段检索角色ID为3的所有用户。 出于某种原因,我收到了数据库错误

'条款'中的未知列'userc.u_id'

   $this->db->join('(SELECT GROUP_CONCAT(data) AS custom_data, id AS dataid, u_id
     FROM ea_user_cfields userc
     GROUP BY id) AS tt', 'userc.u_id = ea.id','left');
    $this->db->join('(SELECT GROUP_CONCAT(name) AS custom_name, id AS customid
     FROM ea_customfields AS cf
     GROUP BY id) AS te', 'userc.c_id = cf.id','left');
    $this->db->where('id_roles', $customers_role_id);



    return $this->db->get('ea_users ea')->result_array();

实际查询:

SELECT * FROM (`ea_users` ea) 

LEFT JOIN (SELECT GROUP_CONCAT(data) AS custom_data, id AS dataid, u_id FROM
ea_user_cfields userc GROUP BY id) AS tt ON `userc`.`u_id` =
`ea`.`id` 

LEFT JOIN (SELECT GROUP_CONCAT(name) AS
custom_name, id AS customid FROM ea_customfields AS cf GROUP BY id) AS
te ON `userc`.`c_id` = `cf`.`id` WHERE `id_roles` = '3'

I am using Codeigniter and I am trying to retrieve all users with role ID 3 with all their saved custom fields. For some reason, I get a database error with

"Unknown column 'userc.u_id' in 'on clause'"

   $this->db->join('(SELECT GROUP_CONCAT(data) AS custom_data, id AS dataid, u_id
     FROM ea_user_cfields userc
     GROUP BY id) AS tt', 'userc.u_id = ea.id','left');
    $this->db->join('(SELECT GROUP_CONCAT(name) AS custom_name, id AS customid
     FROM ea_customfields AS cf
     GROUP BY id) AS te', 'userc.c_id = cf.id','left');
    $this->db->where('id_roles', $customers_role_id);



    return $this->db->get('ea_users ea')->result_array();

Actual query:

SELECT * FROM (`ea_users` ea) 

LEFT JOIN (SELECT GROUP_CONCAT(data) AS custom_data, id AS dataid, u_id FROM
ea_user_cfields userc GROUP BY id) AS tt ON `userc`.`u_id` =
`ea`.`id` 

LEFT JOIN (SELECT GROUP_CONCAT(name) AS
custom_name, id AS customid FROM ea_customfields AS cf GROUP BY id) AS
te ON `userc`.`c_id` = `cf`.`id` WHERE `id_roles` = '3'

原文:https://stackoverflow.com/questions/39450909
更新时间:2023-07-15 13:07

最满意答案

Javadoc提供了非常详细的指导:

更新操作之间允许的并发性由可选的concurrencyLevel构造函数参数(缺省值16)引导,该参数用作内部大小调整的提示。

该表在内部进行分区,以尝试允许指定数量的并发更新而不会发生争用。 因为散列表中的放置基本上是随机的,所以实际的并发性会有所不同。 理想情况下,您应该选择一个值来容纳与同时修改表一样多的线程。 使用比您需要的更高的值会浪费空间和时间,而显着更低的值可能导致线程争用。 但是,在一个数量级内过高估计和低估通常不会产生明显的影响。 当知道只有一个线程会修改而其他所有线程只能读取时,值为1是合适的。

总结: 最佳值取决于预期的并发更新数。 在一个数量级内的值应该很好。 超出该范围的值可能会导致性能下降。


The Javadoc offers pretty detailed guidance:

The allowed concurrency among update operations is guided by the optional concurrencyLevel constructor argument (default 16), which is used as a hint for internal sizing.

The table is internally partitioned to try to permit the indicated number of concurrent updates without contention. Because placement in hash tables is essentially random, the actual concurrency will vary. Ideally, you should choose a value to accommodate as many threads as will ever concurrently modify the table. Using a significantly higher value than you need can waste space and time, and a significantly lower value can lead to thread contention. But overestimates and underestimates within an order of magnitude do not usually have much noticeable impact. A value of one is appropriate when it is known that only one thread will modify and all others will only read.

To summarize: the optimal value depends on the number of expected concurrent updates. A value within an order of magnitude of that should work well. Values outside that range can be expected to lead to performance degradation.

相关问答

更多
  • ConcurrentMap具有条件操作,可保证原子插入/删除和替换键/值对。 此外,访问ConcurrentMap会创建一个先发生过的关系,因此您可以对代码的排序做出某些保证。 在提供的代码中,行: X o = k.get("LL"); 访问键“LL”的当前X值。 下一行修改a属性。 在不知道X的实现的情况下,这是Java,所以我们知道这里没有方法调用。 如果 (且仅当)a属性被标记为volatile,则在“LL”访问X的某些后续代码将看到a值为6.如果它不是volatile,则根本没有保证。 他们可能会 ...
  • 关键是提供一个线程安全的HashMap的实现。 多个线程可以读取和写入它,而不会有接收到过期或损坏的数据的机会。 ConcurrentHashMap提供了自己的同步,因此您不必明确地同步其访问。 ConcurrentHashMap另一个特点是它提供putIfAbsent方法,如果指定的键不存在,它将以原子方式添加映射。 请考虑以下代码: ConcurrentHashMap myMap = new ConcurrentHashMap(); ...
  • Javadoc提供了非常详细的指导: 更新操作之间允许的并发性由可选的concurrencyLevel构造函数参数(缺省值16)引导,该参数用作内部大小调整的提示。 该表在内部进行分区,以尝试允许指定数量的并发更新而不会发生争用。 因为散列表中的放置基本上是随机的,所以实际的并发性会有所不同。 理想情况下,您应该选择一个值来容纳与同时修改表一样多的线程。 使用比您需要的更高的值会浪费空间和时间,而显着更低的值可能导致线程争用。 但是,在一个数量级内过高估计和低估通常不会产生明显的影响。 当知道只有一个线程会 ...
  • 迭代器是否在编辑/删除后刷新其快照?为什么迭代器会以与ADD不同的方式处理更新/删除。 CHM的Iterator在API中进行了解释 类似地,Iterators和Enumerations在迭代器/枚举的创建时或之后的某个时刻返回反映哈希表状态的元素。 这意味着返回的迭代器可能会也可能不会反映迭代时Map中发生的更改。 想象一下,如果您创建迭代器并遍历整个段并转到下一个段。 在您转到下一个段后,您完成遍历的第一个段已完成添加或删除。 好吧,你不会看到那个,没关系,它没有违反API。 至于你的第二个问题。 暗示 ...
  • 由ConcurrentHashMap生成的迭代器是一致的 。 那是: 他们可能会与其他操作同时进行 他们永远不会抛出ConcurrentModificationException 它们保证在构造时只存在一次元素,并且可能(但不保证)反映构造后的任何修改。 最后一个项目符号非常重要,迭代器在创建迭代器后的某个时间点返回地图视图,以引用ConcurrentHashMap中的不同部分javadoc : 类似地,Iterators,Spliterator和Enumerations在创建迭代器/枚举时或之后返回反映哈 ...
  • 在阅读并发级别可以改变的文档时没有理由去思考。 它仍然是在对象创建过程中设置的内容。 如有疑问,请浏览源代码: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/43cb25339b55/src/share/classes/java/util/concurrent/ConcurrentHashMap.java 如果初始容量小于指定的并发级别,它似乎只会增加容器的数量。 There is no reason to think upon reading the docu ...
  • 我认为你的问题是你的一些操作应该是原子的,而不是。 例如,一种可能的线程交错场景如下: 线程1在getData方法中读取此行: if (map.containsKey(name)) // (1) 结果为false并且线程1进入 reply = getDataFromFileSystem(name); // (2) 在getDataFromFileSystem ,您有以下代码: if (map.containsKey(name)) { // (3) map.remove(name); // (4 ...
  • 我想知道,由于数据只是在同步方法中放置,将ConcurrentHashMap的concurrencyLevel设置为1是否安全? 它肯定是安全的,因为它不会导致任何Map损坏。 但是,它不会修复你的内存泄漏。 实际上,您可能不希望同步对ConcurrentHashMap的访问,这已经保证了来自多个线程的安全读取和写入。 外部同步将转向对CHM的单线程访问,这将消除CHM相对于HashMap的许多好处。 如果删除synchronized并指定concurrencyLevel等于估计的并发写入次数 ,则可能会获 ...
  • AbstractMap上的clone()方法不适用于复制,它是一种内部方法,请记下protected关键字。 protected Object clone() throws CloneNotSupportedException { HashMap恰好有一个公共的clone(),但这并不意味着你应该使用它,这将在Effective Java中进一步讨论:clone()方法的分析 创建集合副本的更灵活的方法是通过复制构造函数。 这些优点是可以从任何其他地方创建任何Map实现。 /** * Creates a ...
  • 我使用它来快速查找用户id到多线程服务器中的用户对象。 我有一个网络线程,一个用于周期性任务的计时器线程和一个用于处理控制台输入的线程。 多个线程访问用户的哈希映射,因此它需要是线程安全的。 I use it for quick lookup from user ids to user objects in a multi-threaded server for instance. I have a network-thread, a timer thread for periodical tasks an ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。