这句数据库sql语句如何用exists关键字去写?
表结构如下数据库是mysqlCREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENT,`stuno`varchar(50...
表结构如下
数据库是mysql
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`stuno` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`stuname` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`course` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`score` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
sql语句如下:
DELETE FROM student WHERE id NOT IN (SELECT k.id FROM(SELECT MIN(id) AS id FROM student GROUP BY stuno,stuname,course,score) k);
请将这句话用exists关键字来写 展开
数据库是mysql
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`stuno` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`stuname` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`course` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`score` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
sql语句如下:
DELETE FROM student WHERE id NOT IN (SELECT k.id FROM(SELECT MIN(id) AS id FROM student GROUP BY stuno,stuname,course,score) k);
请将这句话用exists关键字来写 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询