复杂的SELECT SQL语句(Complex SELECT SQL statement)
有一些课程。 课堂上的学生学习科目。 我将这些表格连接到每个表格上:对于1个班级,将有许多科目,对于1个科目,将有许多班级。
Subject M <=> M Class
。 所以我在我的数据库中有3个表来创建这些关系:学科:
+----+------+ + id + name + +----+------+
类:
+----+-------+------+ + id + digit + char + +----+-------+------+
ClassVsTeacher(连接这两个表):
+----+----------+------------+ + id + class_id + subject_id + +----+----------+------------+
TeacherVsClass(对于第二个问题很重要,可以连接课程和教师):
+----+----------+------------+ + id + class_id + teacher_id + +----+----------+------------+
1)我是对的吗?
2)我正在努力将课程添加到课堂上。 我想在下拉列表中显示至少有1位老师的所有科目,除了已经连接的科目。
我知道如何展示至少有一位老师的所有科目:
select `s`.`id`, `s`.`name` from `Subject` as `s` where `s`.`id` in (select `subject_id` from `TeacherVsSubject`)
它工作正常,但我无法理解如何显示这个,除了已经连接到当前类的主题。 这是我的问题。
There are some classes. Students in the classes learn subjects. I connected these tables to each over so: For 1 class there will be many subjects, for 1 subjects there will be many classes.
Subject M <=> M Class
. So I have 3 tables in my database to create these relationships:Subject:
+----+------+ + id + name + +----+------+
Class:
+----+-------+------+ + id + digit + char + +----+-------+------+
ClassVsTeacher (to connect these 2 tables):
+----+----------+------------+ + id + class_id + subject_id + +----+----------+------------+
TeacherVsClass (important for 2nd question, to connect classes and teachers):
+----+----------+------------+ + id + class_id + teacher_id + +----+----------+------------+
1) Am I right?
2) I am working on adding subject to a class now. I want to show in drop-down all subjects which has at least 1 teacher, except subjects current class already connected with.
I know how to show all subjects which has at least 1 teacher:
select `s`.`id`, `s`.`name` from `Subject` as `s` where `s`.`id` in (select `subject_id` from `TeacherVsSubject`)
It works fine, but I can't understand how to show this, except subjects which is already conneted to current class. This is my question.
原文:https://stackoverflow.com/questions/21226640
最满意答案
总结或计算用
counter.inc
报告的计数器的每个任意间隔的计数(总计):hitcount(perSecond(AProcessor.a-req-count.count), '1hour') hitcount(perSecond(AProcessor.a-res-count.count), '1day')
Afaik它完成了所有的黑魔法。 包括但不限于
summarize(scaleToSeconds(nonNegativeDerivative(your.count),1), '1day')
,还应该根据碳的保留期(一个或多个)进行缩放,这些保留期落入选定的聚合间隔。To sum up or calculate count(total) per arbitrary interval for counters reported with
counter.inc
:hitcount(perSecond(AProcessor.a-req-count.count), '1hour') hitcount(perSecond(AProcessor.a-res-count.count), '1day')
Afaik it does all the black magic inside. Including but not limited to
summarize(scaleToSeconds(nonNegativeDerivative(your.count),1), '1day')
and also there should be scaling according to carbon's retention periods (one or many) that fall into chosen aggregation interval.
相关问答
更多-
jQuery计数器+每次重置(jQuery counter + each reset)[2022-06-30]
问题不在于时间,而在于您的summarySlider函数正在查找和操作两个滑块中存在的元素。 您可以为父滑块元素传入另一个参数,并使用find()使其特定于实例 function summarySlider($slider, count) { var itemWidth = '20.2'; var itemList = $slider.find('.summary-item-list'); $(itemList).css('transform', 'translateX(-'+ (itemWid ... -
下载计数器:cgi FieldStorage重置按下的按钮值(Download counter: cgi FieldStorage reset pressed button values)[2021-04-22]
我将为googlers留下一个解决方案。 我通过检查下载文件的人的最后一个IP地址来排序问题。 如果IP与再次下载(重复下载或页面刷新)相同,则不会触发计数器。 它的代码如下: 获取最新IP: ip = (getenv("HTTP_CLIENT_IP") or getenv("HTTP_X_FORWARDED_FOR") or getenv("REMOTE_ADDR") or "UNKNOWN") 获取下载文件的最后一个IP: last_ip_raw = c.execute('SELECT ip FROM ... -
以这种方式设置数据属性实际上不会将data-increment放到按钮上,你必须使用attr()方法,否则$(this).data('increment')将不知道它。 此外,您不必使用if语句进行事件处理,也不需要在函数中。
应该有/在结尾而不是在开始。 请参阅下面的工作代码段: var counter = 0; function count() { $('#notify').addClass("notification"); $("#notify").html(counter ... -
从Android传感器API : 公共静态最终诠释TYPE_STEP_COUNTER 这种类型的传感器返回自上次重新启动后用户采取的步骤数 。 该值以浮点形式返回(小数部分设置为零),并且仅在重新引导系统时重置为零 。 (强调我的) 正如你所看到的,当传感器被激活时,在系统重新启动之前,该值不会重置为零。 如果您希望每次启动应用程序时从0开始计数,您可以将返回的第一个值存储为初始值,然后减去后续值。 From Android Sensor API: public static final int TYPE_ ...
-
总结或计算用counter.inc报告的计数器的每个任意间隔的计数(总计): hitcount(perSecond(AProcessor.a-req-count.count), '1hour') hitcount(perSecond(AProcessor.a-res-count.count), '1day') Afaik它完成了所有的黑魔法。 包括但不限于summarize(scaleToSeconds(nonNegativeDerivative(your.count),1), '1day') ,还应该 ...
-
如何重置依赖于actionsButtons的计数器 - 闪亮?(How to reset a counter that depends of actionsButtons - Shiny?)[2023-05-07]
这是你想要的? library(shiny) library(DT) ui <- fluidPage( sidebarPanel(numericInput("c1", "Example", NA), tags$p(actionButton("update", "Update")), tags$p(actionButton("reset", "Clear")), tags$p(actionButton("resta ... -
我认为这是一个范围问题,你可以像这样修改重置函数: function Reset { $script:countercorrect = 0 } I think this is a scope issue ,can you modify the reset function like this: function Reset { $script:countercorrect = 0 }
-
你有Maximum value领域,如果你有3而不是那个奇怪的价值,你现在有计数器将开始行为完全按照你所期望的行为。 更多信息: 如何在JMeter测试中使用计数器 You have Maximum value field, if you put there 3 instead of that weird value you currently have the Counter will start behaving exactly as you expect it do behave. More info ...
-
计数器重置java(counter gets reset java)[2022-08-19]
就像shekhar所说,你需要将代码更新为count +=1或者是安全count = count + 1 就像CDahn所说的那样,变量count必须是静态的,因为它必须保持对函数调用的价值 每次调用GuessMachine ,计数都会被重置。 想想GuessMachine将如何被一次又一次地召唤。 这意味着您将一次又一次地在GuessMachine函数的顶部执行count = 0 。 你需要从GuessMachine函数中初始化count = 0并进入函数main因为即使你将它设置为静态,如果你每次调用G ... -
如何重置点击计数器?(How to reset a click counter?)[2022-02-16]
您还必须将变量counter设置回0。 所以你的“重置”功能应该是这样的: public void btn_aprove (View view) { count.setText("0"); counter = 0; } You also have to set the variable counter back to 0. So your "Reset"-function should look like this: public void ...