If judgment in MySQL

Source: Internet
Author: User

The problem is that there is a table (Tb_class) that specifically holds the class ID and class name

Another table is the Student Information table (TB_STU), the table has a field called ClassID, there is no foreign key association, now you want to flush this table to another table tb_partment, the table ClassID (can be null) associated with the ID in Tb_class, Therefore, it is necessary to judge if the ClassID in Tb_stu is not in Tb_class, then the ClassID in Tb_stu is set to null.

This can be implemented in the DAO layer of Java, but I think this should also be implemented in MySQL, in the Tb_stu data to the memory, or memory in the memory of the data inserted into the tb_partment can be judged by an if, and this judgment is done in MySQL. Now, write down the question first. Because I'm not going to do it now.

If judgment in MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.