检索出 stu表中‘计算机工程’或‘软件工程’专业的学生的记录,结果集按学号升序排序。 表结构: 请在这里写定义表结构的SQL语句。例如: CREATE TABLE `major` ( `mno` char(2) NOT NULL, `mname` varchar(20) NOT NULL, PRIMARY KEY (`mno`) ); CREATE TABLE `stu` ( `sno` char(4) NOT NULL, `sname` char(8) NOT NULL, `sex` tinyint(1) DEFAULT NULL, `mno` char(2) DEFAULT NULL, `birdate` datetime DEFAULT NULL, `memo` text, PRIMARY KEY (`SNO`), CONSTRAINT fk_stu_mno FOREIGN KEY (mno) REFERENCES major (mno) );
时间: 2023-10-21 19:05:32 浏览: 147
CREATE TABLE `major` (
`mno` char(2) NOT NULL,
`mname` varchar(20) NOT NULL,
PRIMARY KEY (`mno`)
);
CREATE TABLE `stu` (
`sno` char(4) NOT NULL,
`sname` char(8) NOT NULL,
`sex` tinyint(1) DEFAULT NULL,
`mno` char(2) DEFAULT NULL,
`birdate` datetime DEFAULT NULL,
`memo` text,
PRIMARY KEY (`sno`),
CONSTRAINT `fk_stu_mno` FOREIGN KEY (`mno`) REFERENCES `major` (`mno`)
);
SELECT * FROM stu WHERE mno IN (SELECT mno FROM major WHERE mname IN ('计算机工程', '软件工程')) ORDER BY sno ASC;
阅读全文