Luis Lebron <[EMAIL PROTECTED]> wrote:
> 
> I am try to copy a couple of fields from one table to another. Here is my
> query
> 
> Insert into users_test (firstName, lastName) Select firstName, lastName from
> users;
> 
> The users table has 1,263 rows. However, only 1 row is inserted into
> users_test. 
> 
> If I perform the following query 
> 
> Insert into users_test Select * users;
> 
> all the rows are inserted. What am I doing wrong in the first query?
> 

Worked perfect for me:

mysql> create table i1(
    -> firstname varchar(10),
    -> lastname varchar(10));
Query OK, 0 rows affected (0.00 sec)

mysql> create table i2(
    -> firstname varchar(10),
    -> lastname varchar(10));
Query OK, 0 rows affected (0.00 sec)

mysql> insert into i1 values('aaa','aaa'),('bbb','bbb'),('ccc','ccc');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> insert into i2(firstname, lastname) select firstname, lastname from i1;
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from i2;
+-----------+----------+
| firstname | lastname |
+-----------+----------+
| aaa       | aaa      |
| bbb       | bbb      |
| ccc       | ccc      |
+-----------+----------+
3 rows in set (0.00 sec)

mysql> truncate i2;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into i2 select * from i1;
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql>
mysql> select * from i2;
+-----------+----------+
| firstname | lastname |
+-----------+----------+
| aaa       | aaa      |
| bbb       | bbb      |
| ccc       | ccc      |
+-----------+----------+
3 rows in set (0.00 sec)



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to