简体   繁体   English

MySQL如何使表中的一个字段依赖于其他字段是否具有值?

[英]mySQL how to make one field in table dependant on if some other field has a value?

im bulding a website using html/php/js/mysql 我使用html / php / js / mysql建立网站

I have a from on website where i need to enter Students ID and name of a course that student has passed, but some courses are dependant on other(example: i need to pass Calculus 1 before i can enter my Calculus 2 grade). 我在网站上有一个from站点,我需要输入学生ID和该学生已通过的课程的名称,但是有些课程取决于其他课程(例如:我需要通过Calculus 1才能进入我的Calculus 2成绩)。

I need to check that data usig AJAX(example: if i try to enter grade from Calculus 2, but Calculus 1 is not completed(no grade) i need to msg an error) and if all conditions are fulfilled then i proceed to enter data. 我需要检查数据是否使用AJAX(例如:如果我尝试从微积分2输入成绩,但微积分1尚未完成(没有成绩),我需要输入错误消息),如果所有条件都得到满足,那么我将继续输入数据。

What realy bugs me here: is there a way so i can make that kind of dependancy in mySQL? 有什么真正的问题困扰我:有没有办法让我可以在mySQL中进行这种依赖? (i want to make Calculus 2 dependant on Calculus 1 value). (我想使微积分2取决于微积分1的值)。

I hope that someone will understand my question and help me. 我希望有人能理解我的问题并为我提供帮助。 Thanks 谢谢

What you are asking is something that is supposed to be fulfilled by the logic of your program's code and not the SQL database. 您要问的是应该由程序代码的逻辑而非SQL数据库来实现的。 The database is only meant to store the data not doing logic based on said data. 该数据库仅用于存储不基于所述数据进行逻辑运算的数据。

The only kind of logic that SQL really does is transforming the data based on table aggregations or analyze data for patterns. SQL真正执行的唯一逻辑是基于表聚合转换数据或分析数据的模式。 It can do other stuff like force numbers in a certain table to never repeat. 它可以做其他事情,例如某个表中的强制编号,以永不重复。

Not allowing a table to have data unless another does is not part of the logic SQL handles. 不允许表具有数据,除非另一个表没有数据,这不是逻辑SQL句柄的一部分。 If you tell it to put data in a table then it will do it. 如果您告诉它将数据放在表中,那么它将完成该操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mysql如何根据一个字段和另一个表中的一个字段显示表的某些行? - mysql how to show some rows of table depending on one field and depending on one field in other table? 如何从MySQL表中提取两个具有相同字段值而另一字段不同的行? - How do I pull two rows from a MySQL table that have one field value in common and the other field different? 如何在与其他表有关系的字段中存储多个值 - How to store multiple value in a field which has relationship with other table 如何从MySQL中的索引字段输出另一个表的值? - How to output a value of an other table from an indexed field in mySQL? MySQL如何将数据从一个字段复制到同一表的另一个字段 - Mysql how to copy data from one field to other field in same table MYSQL连接具有相同字段值的两个表字段,但如果另一个字段与另一个字段不匹配,则仍将包括 - MYSQL Join two table fields with same field value but will still include if the other field doesn't match the other one 使用PHP和MySQL如何使用另一个表中的某些字段值填充一个表 - Using PHP and MySQL how do I populate one table using some field values from another table 如果其他字段有价值,则需要一个字段 - Require a field if other field has value MYSQL计算SOME值作为表的字段中的值存在的次数 - MYSQL count how many times SOME value is exist as value in a field of table 连接 Function 用于将一个表中的字段值与另一表匹配 - Join Function used to match value of field in one table with other table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM