INSERT INTO New_Mydata
(Nameid, Allc1, Allc2, Allc3, Allc4, ALL)
SELECT Nameid,
SUM(CASE Allc WHEN '满意' THEN 1 ELSE 0 END),
SUM(CASE Allc WHEN '一般' THEN 1 ELSE 0 END),
SUM(CASE Allc WHEN '不满意' THEN 1 ELSE 0 END),
SUM(CASE Allc WHEN '未平' THEN 1 ELSE 0 END),
SUM(*)
FROM Mydat
GROUP BY Nameid
SELECT SUBSTRING_INDEX(name, '=', 1) AS city, SUBSTRING_INDEX(name, '=', -1) AS name FROM TB_USER上面那个是用于查询的,如果是想修改数据库,则用下面的语句:
ALTER TABLE TB_USER
ADD COLUMN city VARCHAR(16) NULL
UPDATE TB_USER SET city = SUBSTRING_INDEX(name, '=', 1),
name = SUBSTRING_INDEX(name, '=', -1)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)