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? Link to comment https://forums.phpfreaks.com/topic/7037-help-with-connecting-two-tables/ 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. Link to comment https://forums.phpfreaks.com/topic/7037-help-with-connecting-two-tables/#findComment-25594 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? Link to comment https://forums.phpfreaks.com/topic/7037-help-with-connecting-two-tables/#findComment-25869 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. Link to comment https://forums.phpfreaks.com/topic/7037-help-with-connecting-two-tables/#findComment-25970 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? Link to comment https://forums.phpfreaks.com/topic/7037-help-with-connecting-two-tables/#findComment-26105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.