please can someone help i have been working on this query for hours. i am trying to copy certain columns from my table ptb_registrations and insert them as a new row into ptb_users.
my ptb_registrations table looks like this:
id | username | password | firstname | lastname | email 1 dave password james tanner [email protected] 2 jonx10 gundam00 eric davies [email protected] 3 33csgge henry10 daniel gilmart [email protected] from these columns i only want to insert id, firstname, lastname, email and password NOT username.
So my ptb_user table looks like this:
id | user_id | password | firstname | lastname | email 1 1 password james tanner [email protected] 2 2 gundam00 eric davies [email protected] 3 3 henry10 daniel gilmart [email protected] id is an auto increment value, and i want user_id to have the same value as the auto_incremented id column when the data is inserted too (if this is possible so where id is 1 - user_id will be 1 also)
so far i have tried loads of different ways to get the columns inserted from ptb_registrations and into ptb_users but nothing is working for me.
cans someone please show me where i am going wrong, thank you.
// Make a safe query $query ="insert into ptb_users(id, first_name) select ptb_registrations.id, ptb_registrations.firstname from ptb_registrations, temp where ptb_users.id=temp.id; "; mysql_query($query)or die('Could not update members: ' . mysql_error());
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which.