首页 \ 问答 \ 基于来自其他表的值计算(*)行(Count (*) rows based on values from other table)

基于来自其他表的值计算(*)行(Count (*) rows based on values from other table)

记录表

record_id  type_id   title
---------  -------   -----
1          1         Title1
2          2         Title2
3          1         Title3
4          2         Title4

记录价值

id   record_id   field_id  field_value
--   ---------   --------  -----------
1    1           8         active 
2    2           12        some value
3    1           16        lenght
4    2           3         some value

我想计算记录FROM记录表,其中type_id是= 1 AND FROM记录值表field_id_8字段值=活动AND field_id_16字段值= lenght。

基于上面的两个示例表,查询返回1( record_id = 1是唯一适合查询的行)。

我可以创建简单的MYSQL查询,但我无法解决这个问题。 任何人都可以帮助我?


RECORD TABLE

record_id  type_id   title
---------  -------   -----
1          1         Title1
2          2         Title2
3          1         Title3
4          2         Title4

RECORD VALUES

id   record_id   field_id  field_value
--   ---------   --------  -----------
1    1           8         active 
2    2           12        some value
3    1           16        lenght
4    2           3         some value

I want to count records FROM record table which type_id is = 1 AND FROM record values table field_id_8 field value = active AND field_id_16 field value = lenght.

Based on the two example table above the query return 1 (record_id = 1 is the only one row which fit to query).

I can create simple MYSQL queries but I can't do anything to solve this one. Anyone can help me?


原文:https://stackoverflow.com/questions/29880903
更新时间:2022-10-17 18:10

最满意答案

只需针对返回的代码执行上面的代码:

例如:

function doit(obj){
    $(obj).each( // rest of your function
}

// ...

$.get(...).done(function(data){
    var obj = $(data);
    doit(obj);
    // rest of your injection
}

There is a function ajaxSuccess in jQuery which can be used to do something after all ajax calls.

 $(document).ajaxSuccess(function() {
                accessControl.checkAccessControl();
    });

相关问答

更多
  • 我发现当你专门为iOS应用程序使用javascript时,由于记忆开销,你需要非常小心使用jQuery。 我经常不得不在本机javascript中重写jQuery重要的javascript部分,以减少记忆足迹并确保它在iOS环境中有效工作。 我发现在这种情况下调试的最佳方法是在谷歌浏览器中使用分析器。 刚刚回答了类似的问题,请点击此处获取更多信息: 使用“JQuery.on()”是否存在任何可能的危险 使用chrome Profiler时,请获取堆快照,进行更改,然后再拍摄另一个堆快照并进行比较。 这样可以 ...
  • 使用.on() $(document).on('click','#newDiv img',function(){ }); use .on() $(document).on('click','#newDiv img',function(){ });
  • 注意:这些id不能被复制。 您已经多次使用id="search" 。 您需要使用上下文相关的 this关键字: $(function() { $("input").on("mouseover", function() { var a = $(this).attr('name'); populate(a); }); }); 回答你的问题: 原因是,您正在第一个匹配元素上执行.attr() ( 它是仅处理一个元素的许多函数之一 )。 Note: The ids are not mean ...
  • 只需针对返回的代码执行上面的代码: 例如: function doit(obj){ $(obj).each( // rest of your function } // ... $.get(...).done(function(data){ var obj = $(data); doit(obj); // rest of your injection } There is a function ajaxSuccess in jQuery which can be use ...
  • 您应该阅读JQuery中的事件冒泡以及事件发生的顺序,但一个简单的解决方案可能是添加: return false 到您的点击功能的末尾。 这将防止他们的事件冒泡。 You should read up on event bubbling in JQuery, as well as what order events happen, but a simple solution might be to add: return false To the end of your click functions. ...
  • 我很快尝试使用您的代码重新创建您的情况,但图片不可拖动。 您是否遗漏了您使用的基本代码或信息? 我将尝试解决这个问题,因为到目前为止还没有人跳过它。 只需给我更多代码,因为看起来当前给定的代码不起作用。 I quickly tried to use your code to recreate your situation, but the pictures aren't draggable. Are you leaving out some essential code you used, or infor ...
  • 尝试这个 $(document).on('click','.clsName',function(){ //code here }); try this $(document).on('click','.clsName',function(){ //code here });
  • 为了避免你所描述的效果,你可以反转你的逻辑并最初用你随后显示的css隐藏所有元素 to avoid the effect you are describing you could just reverse your logic and initially hide all elements with css you then show
  • 解决这个问题的一个更简单的方法是将相同的负载处理程序附加到所有的iframe中,维护一个计数器,然后在发生所需数量的负载事件后运行您的代码: