brown2005 Posted April 10, 2006 Share Posted April 10, 2006 Hey....I have table 1---------------------field - letter and have 26 records for this then i have table 2--------------------fields - table2_id and table2_letterand 26 records for this.what i want to do is select a letter from table 1 and put it in field table2_letter but not duplicate itany ideas please? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 10, 2006 Share Posted April 10, 2006 As you have 26 recs in table2, adding a 27th without duplication could be difficult. Quote Link to comment Share on other sites More sharing options...
brown2005 Posted April 11, 2006 Author Share Posted April 11, 2006 sorry i dont think u understood,what i want to do is take the 26 records from the one table and enter them into the a field in the other table without any duplicates? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 11, 2006 Share Posted April 11, 2006 If you want them in the same sequence[code]INSERT INTO table2 (letter) SELECT letter FROM table1[/code]If you want them in a random sequence[code]INSERT INTO table2 (letter) SELECT letter FROM table1 ORDER BY RAND()[/code]This assumes table2.id is auto_increment column. Quote Link to comment Share on other sites More sharing options...
brown2005 Posted April 12, 2006 Author Share Posted April 12, 2006 Thanks that inserts them, but what happens if i already have the records in the table and want to update them? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.