Not able to create a new table new_table from t1 by comparing primary key values of another table t2 in MYSQL I am trying to create a new table new_table from t1 by comparing primary key values of another table t2

ie,
      1) created table new_table

  2) gave the query

insert into new_table select a.* from t1 as a join t2 as b on a.primary_key=b.primary_key.


but after the execution i got a message ( 0 rows affected )

please specify the reason for this.
I'd have to assume that no matching values exist in the tables' respective primary key columns.

mysql&gt; create database testing;
Query OK, 1 row affected (0.02 sec)

mysql&gt; use testing;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql&gt; create table foo (id int);
Query OK, 0 rows affected (0.00 sec)

mysql&gt; create table bar (id int);
Query OK, 0 rows affected (0.00 sec)

mysql&gt; create table baz (id int);
Query OK, 0 rows affected (0.00 sec)

mysql&gt; insert into foo values (1), (2), (3);
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql&gt; insert into bar values (4), (5), (6);
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql&gt; insert into baz select a.* from foo a join bar b on a.id = b.id;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql&gt; insert into bar values (1), (2);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql&gt; insert into baz select a.* from foo a join bar b on a.id = b.id;
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql&gt;