首页 \ 问答 \ 复杂的SELECT SQL语句(Complex SELECT SQL statement)

复杂的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
更新时间:2022-04-29 12:04

最满意答案

总结或计算用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.

相关问答

更多
  • 问题不在于时间,而在于您的summarySlider函数正在查找和操作两个滑块中存在的元素。 您可以为父滑块元素传入另一个参数,并使用find()使其特定于实例 function summarySlider($slider, count) { var itemWidth = '20.2'; var itemList = $slider.find('.summary-item-list'); $(itemList).css('transform', 'translateX(-'+ (itemWid ...
  • 我将为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') ,还应该 ...
  • 这是你想要的? 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 ...
  • 就像shekhar所说,你需要将代码更新为count +=1或者是安全count = count + 1 就像CDahn所说的那样,变量count必须是静态的,因为它必须保持对函数调用的价值 每次调用GuessMachine ,计数都会被重置。 想想GuessMachine将如何被一次又一次地召唤。 这意味着您将一次又一次地在GuessMachine函数的顶部执行count = 0 。 你需要从GuessMachine函数中初始化count = 0并进入函数main因为即使你将它设置为静态,如果你每次调用G ...
  • 您还必须将变量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 ...

相关文章

更多

最新问答

更多
  • 如何检索Ember.js模型的所有属性(How to retrieve all properties of an Ember.js model)
  • maven中snapshot快照库和release发布库的区别和作用
  • arraylist中的搜索元素(Search element in arraylist)
  • 从mysli_fetch_array中获取选定的值并输出(Get selected value from mysli_fetch_array and output)
  • Windows Phone上的可用共享扩展(Available Share Extensions on Windows Phone)
  • 如何在命令提示符下将日期设置为文件名(How to set file name as date in command prompt)
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • 从iframe访问父页面的id元素(accessing id element of parent page from iframe)
  • linux的常用命令干什么用的
  • Feign Client + Eureka POST请求正文(Feign Client + Eureka POST request body)
  • 怎么删除禁用RHEL/CentOS 7上不需要的服务
  • 为什么Gradle运行测试两次?(Why does Gradle run tests twice?)
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在android中的活动之间切换?(Switching between activities in android?)
  • Perforce:如何从Depot到Workspace丢失文件?(Perforce: how to get missing file from Depot to Workspace?)
  • Webform页面避免运行服务器(Webform page avoiding runat server)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 内存布局破解(memory layout hack)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • 我们可以有一个调度程序,你可以异步添加东西,但会同步按顺序执行吗?(Can we have a dispatcher that you can add things todo asynchronously but will be executed in that order synchronously?)
  • “FROM a,b”和“FROM a FULL OUTER JOIN b”之间有什么区别?(What is the difference between “FROM a, b” and “FROM a FULL OUTER JOIN b”?)
  • Java中的不可变类(Immutable class in Java)
  • bat批处理文件结果导出到txt
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • 德州新起点计算机培训学校主要课程有什么?
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • “latin1_german1_ci”整理来自哪里?(Where is “latin1_german1_ci” collation coming from?)