Skip to content

Instantly share code, notes, and snippets.

@uhpd
Created December 24, 2014 16:28
Show Gist options
  • Save uhpd/abf52abc53f72ca58628 to your computer and use it in GitHub Desktop.
Save uhpd/abf52abc53f72ca58628 to your computer and use it in GitHub Desktop.
de-6
create database de6
use de6
alter table mon add
constraint cheack_e cheack (sotinchi between 1 and 4)
create trigger temp
on sinhvien
for insert,update
as
begin
declare
@namsinh smalldatetime
@namhoc smalldatetime
select @namhoc=namhoc
from inserted a join dangky b
on a.masv=b.masv
if(@namsinh >@namhoc)
begin
print 'Nam hoc dang ky phai lon hon nam sinh'
rollback trancation
end
end
create trigger temp
on namhoc
for insert,update
--Liệt kê danh sách các sinh viên (Masv, Hoten) học chuyên ngành ‘He thong thong tin’
select masv,hoten
from sinhvien a join chuyennganh b
on a.macn=b.macn
where tencn='He thong'
--Liệt kê những sinh viên (Masv, Hoten) thuộc chuyện ngành “He thong thong tin” chưa đăng
--ký học môn ‘PTTKHTTT’
select masv,hoten
from sinhvien a join chuyennganh b
on a.macn=b.macn
where tencn='He thong' and macn not in(select macn
from chuyennganh
where macn = pttkhtt')
--Tìm những sinh viên (Masv, Hoten) đã đăng ký tất cả các môn thuộc chuyên ngành ‘He thong
--thong tin’
select macn,hoten
from sinhvien
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment