这是我的FIDDLE.
我试图将数据从旧表导入新表.在旧表中,有许多没有重复.在新表中,我只能插入DISTINCT电子邮件.我无法将名称插入相同的名称.这是我的代码.
CREATE TABLE table_old(name VARCHAR(255),email VARCHAR(255));
INSERT INTO table_old (name,email) VALUES ('tom','tom@gmail.com'),('peter','peter@gmail.com'),('hitler','hitler@gmail.com'),('haasan','haasan@gmail.com'),('arun','arun@gmail.com'),('tom','arun@gmail.com');
CREATE TABLE table_new AS (SELECT DISTINCT email FROM table_old );
最佳答案
我想这就是你所追求的:
原文链接:https://www.f2er.com/mysql/433124.htmlCREATE TABLE table_new AS (SELECT name,email FROM table_old GROUP BY name,email);