This topic requires writing a DELETE statement to delete the course selection records of girls who take the 'C language' course.
Table Structure:
Please write the SQL statement that defines the table structure here. For example:
CREATE TABLE `stu` (
`sno` char(4) NOT NULL,
`sname` char(8) NOT NULL,
`sex` tinyint(1) DEFAULT NULL, --0为女生,1为男生。
`mno` char(2) DEFAULT NULL,
`birdate` datetime DEFAULT NULL,
`memo` text,
PRIMARY KEY (`sno`)
);
CREATE TABLE `cou` (
`cno` char(4) NOT NULL,
`cname` varchar(30) NOT NULL,
`credit` smallint(6) DEFAULT NULL,
`ptime` char(5) DEFAULT NULL,
`teacher` char(10) DEFAULT NULL,
PRIMARY KEY (`cno`)
)
CREATE TABLE `sc` (
`sno` char(4) NOT NULL,
`cno` char(4) NOT NULL,
`grade` decimal(6,1) DEFAULT NULL,
PRIMARY KEY (`sno`,`cno`),
CONSTRAINT `fk_sc_cno` FOREIGN KEY (`cno`) REFERENCES `cou` (`cno`),
CONSTRAINT `fk_sc_sno` FOREIGN KEY (`sno`) REFERENCES `stu` (`sno`)
)
table sample
Please give a table sample corresponding to the above table structure here. For example
Stu table:
cou table:
sc table:
Sample output:
After deleting the record, the sc table is as follows:
Code length limit 16 KB
Time limit 400 ms
DatabaseMySQL
The result output requires a strict comparison of the order and data
delete from sc
where sno in(
select sno
from stu
where sex = 0
)and cno in(
select cno
from cou
where cname = 'C语言'
)