在SQL Server中不重叠数据 [英] not overlap data in sql server

查看:72
本文介绍了在SQL Server中不重叠数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在sql server中有这样的表

student_ID课程月份标记


学生每个月都会获得分数
我想如果6月份标记在特定学生ID的数据库中,则它不会再次存储在其上.但是在7月份,数据将存储给具有相同ID的同一学生.

但我不想在同一个月存储标记.


请帮助
谢谢

hi guys,


i have a table in sql server like this

student_ID Course month mark


student get a mark in each month
i want if a june mark is in databse for particular student id then it not store again on it. But in july month data is store for same student with same Id.

but i dont want to store a mark on same month.


please help
thanks

推荐答案

您需要对student_ID,Course和Month的列组合进行唯一约束.
You need a unique constraint on the column combination of student_ID, Course and Month.


这篇关于在SQL Server中不重叠数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆