Here is my FIDDLE .
I am trying to import data from an old table into a new table. The old table has many repetitions. In the new table, I can only insert DISTINCT emails. I cannot Insert a name as one and the same. Here is my code.
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', 'tom@gmail.com'),
('peter', 'peter@gmail.com'),
('hitler', 'hitler@gmail.com'),
('haasan', 'haasan@gmail.com'),
('arun', 'arun@gmail.com');
CREATE TABLE table_new AS (SELECT DISTINCT email FROM table_old );
So let me understand how to insert names in table_new in relation to the email column name.
source
share