Jump to content

Archived

This topic is now archived and is closed to further replies.

brown2005

help with connecting two tables

Recommended Posts

Hey....

I have

table 1
---------------------

field - letter

and have 26 records for this

then i have

table 2
--------------------

fields - table2_id and table2_letter

and 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 it

any ideas please?

Share this post


Link to post
Share on other sites
As you have 26 recs in table2, adding a 27th without duplication could be difficult.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks that inserts them, but what happens if i already have the records in the table and want to update them?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.