6个回答

baidu_36535810 想的是这些数据能放到表1里，因为这个是想做数据挖掘，在处理数据，真实的字段要有900多条，

SELECT
t.teacher,
locate('语文',t.class) AS '语文',
CASE
WHEN locate('数学',t.class) > 0
THEN 1
ELSE 0
END AS '数学',
CASE
WHEN locate('英语',t.class) > 0
THEN 1
ELSE 0
END AS '英语',
CASE
WHEN locate('化学',t.class) > 0
THEN 1
ELSE 0
END AS '化学',
CASE
WHEN locate('物理',t.class) > 0
THEN 1
ELSE 0
END AS '物理',
CASE
WHEN locate('生物',t.class) > 0
THEN 1
ELSE 0
END AS '生物'
FROM
Teacher t;
SELECT
*
FROM
Teacher;

SELECT
t.teacher,
locate('语文',t.class) AS '语文',
CASE WHEN locate('数学',t.class) > 0 THEN 1 ELSE 0 END AS '数学',
CASE WHEN locate('英语',t.class) > 0 THEN 1 ELSE 0 END AS '英语',
CASE WHEN locate('化学',t.class) > 0 THEN 1 ELSE 0 END AS '化学',
CASE WHEN locate('物理',t.class) > 0 THEN 1 ELSE 0 END AS '物理',
CASE WHEN locate('生物',t.class) > 0 THEN 1 ELSE 0 END AS '生物'
FROM Teacher t;

SELECT
t.teacher,
CASE WHEN locate('语文',t.class) > 0 THEN 1 ELSE 0 END AS '语文',
CASE WHEN locate('数学',t.class) > 0 THEN 1 ELSE 0 END AS '数学',
CASE WHEN locate('英语',t.class) > 0 THEN 1 ELSE 0 END AS '英语',
CASE WHEN locate('化学',t.class) > 0 THEN 1 ELSE 0 END AS '化学',
CASE WHEN locate('物理',t.class) > 0 THEN 1 ELSE 0 END AS '物理',
CASE WHEN locate('生物',t.class) > 0 THEN 1 ELSE 0 END AS '生物'
FROM Teacher t;

`````` DROP PROCEDURE IF EXISTS SP_TEST;

DELIMITER \$\$

CREATE PROCEDURE SP_TEST()
BEGIN

DECLARE i INT DEFAULT 0;

SELECT COUNT(*) INTO @COUNT FROM t2;

WHILE i < @COUNT DO

SELECT t2.teacher, t2.course INTO @TEACHER, @COURSE FROM t2 LIMIT I,1;

IF( LOCATE('chinese', @COURSE) > 0 ) THEN SET @CHINESE = 1; ELSE SET @CHINESE = 0; END IF;
IF( LOCATE('math', @COURSE) > 0 ) THEN SET @MATH = 1; ELSE SET @MATH = 0; END IF;
IF( LOCATE('English', @COURSE) > 0 ) THEN SET @ENGLISH = 1; ELSE SET @ENGLISH = 0; END IF;
IF( LOCATE('chemistry', @COURSE) > 0 ) THEN SET @CHEMISTRY = 1; ELSE SET @CHEMISTRY = 0; END IF;
IF( LOCATE('physics', @COURSE) > 0 ) THEN SET @PHYSICS = 1; ELSE SET @PHYSICS = 0; END IF;
IF( LOCATE('biology', @COURSE) > 0 ) THEN SET @BIOLOGY = 1; ELSE SET @BIOLOGY = 0; END IF;

IF ( SELECT COUNT(*) FROM t1 WHERE teacher = @TEACHER ) THEN DELETE FROM t1 WHERE teacher = @TEACHER; END IF;
INSERT INTO t1(teacher,chinese,math,English,chemistry,physics,biology) SELECT @TEACHER, @CHINESE, @MATH, @ENGLISH, @CHEMISTRY, @PHYSICS, @BIOLOGY;
SET i = i + 1;

END WHILE;

END\$\$
DELIMITER ;
``````

-
-

-

-

-
C语言编译NBA数据分析系统怎么连接数据库？
-
Idea 访问数据库报错求教大神
-
navicat连接不上数据库
-
java提取sql server 2000 数据（相同结构的超过100+的数据库）
-
Win8 APP开发连接本地Sqlserver数据库
-

-

-

-
java连接数据库问题，
-

-

-

-

-

redis——相关问题汇总

MySQL数据库—SQL汇总

java中的Static、final、Static final各种用法

HTML CSS整理笔记

linux系列之常用运维命令整理笔录

Python 基础（一）：入门必备知识
Python 入门必备知识，你都掌握了吗？

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。

Docker 技术发展为微服务落地提供了更加便利的环境，使用 Docker 部署 Spring Boot 其实非常简单，这篇文章我们就来简单学习下。首先构建一个简单的 S...

python学习目录

25 篇 Java 入门技术博文，送给正在自学的你