If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Copy data to auto_incremen field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-01-05, 11:30
bono56 bono56 is offline
Registered User
 
Join Date: May 2004
Posts: 133
Copy data to auto_incremen field

i want to divide one Table(tbl1) in 2 table(tbl1,tbl2):
for this i use this statements:
tbl1 have these filds:
Code:
CREATE TABLE `tbl1` (
  `tbl1_id` int(10) unsigned NOT NULL default '0' auto_increment,
  `tbl2_id` int(10) unsigned NOT NULL default '0',
  `tbl1_txt` varchar(100) NOT NULL default '',
  `tbl1_num` int(20) NOT NULL default 0,
   PRIMARY KEY  (`tbl1_id`)
)
i ADD tbl2_id to this table and fill it with this statement:
Code:
UPDATE `tbl1` SET `tbl2_id` = tbl1_id ;
first create tbl2:
Code:
CREATE TABLE `tbl2` (
  `tbl2_id` int(10) unsigned NOT NULL default '0' auto_increment,
  `tbl2_txt` varchar(100) NOT NULL default '',
   PRIMARY KEY  (`tbl2_id`)
)
& then copy data from tbl1 to tbl2 in this way:
Code:
INSERT INTO tbl2
(tbl2_id, tbl2_txt)
SELECT 
tbl1_id, tbl1_txt
FROM 
tbl1;
& then DROP some feilds from tbl1.

note that i want to make a relation bet. tbl1 & tbl2 with tbl2_id field.
& the problem is that i cant copy tbl1_id values into the tbl2_id because of being

auto_increment.
this problem occur in Linux OS, i haven't this prob. in windows OS.

Last edited by bono56; 03-01-05 at 11:36. Reason: Edit
Reply With Quote
  #2 (permalink)  
Old 03-02-05, 07:22
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
What is the reason you are dividing the table in the first place?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On