实现查询学生未选课程的sql语句
时间:2010-08-28 来源:范尼是德鲁伊
表结构
-- ------------------------------ Table structure for class-- ----------------------------CREATE TABLE `class` ( `cname` varchar(30) NOT NULL, `meets_at` time NOT NULL, `room` varchar(20) NOT NULL, `fid` int(11) NOT NULL, PRIMARY KEY (`cname`), KEY `F_fid` (`fid`), CONSTRAINT `F_fid` FOREIGN KEY (`fid`) REFERENCES `faculty` (`fid`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
-- ------------------------------ Table structure for enrolled-- ----------------------------CREATE TABLE `enrolled` ( `snum` int(11) NOT NULL, `cname` varchar(30) NOT NULL, PRIMARY KEY (`snum`,`cname`), KEY `F_cname` (`cname`), CONSTRAINT `F_cname` FOREIGN KEY (`cname`) REFERENCES `class` (`cname`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `F_snum` FOREIGN KEY (`snum`) REFERENCES `student` (`snum`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
-- ------------------------------ Table structure for faculty-- ----------------------------CREATE TABLE `faculty` ( `fid` int(11) NOT NULL, `fname` varchar(20) NOT NULL, `deptid` int(11) NOT NULL, `password` varchar(20) NOT NULL default '123', PRIMARY KEY (`fid`)) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
-- ------------------------------ Table structure for student-- ----------------------------CREATE TABLE `student` ( `snum` int(11) NOT NULL, `sname` varchar(20) NOT NULL, `major` varchar(20) NOT NULL, `level` varchar(20) NOT NULL, `age` int(11) NOT NULL, `password` varchar(20) NOT NULL default '123', PRIMARY KEY (`snum`)) ENGINE=InnoDB DEFAULT CHARSET=gb2312;