View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 07:57 AM
TB
 
Posts: n/a
Default adding a column with data

How do I add a new column with data to an existing table, ensuring
correct record matching, using SQL?

Situation:

I have a table named 'maintable' with 5 columns (ID, firstname,
lastname, phone and fax) and 1000 records. ID is the primary key. Now I
need to add (import) a new column (cellphone) already containing data
from a one-column table called 'extratable'.

The order of the records in both tables are identical, in other words
the cellphone number in record 37 of the table 'extratable' corresponds
to record 37 the table 'maintable'.

Or would it be better to create a new table, merging the two existing
tables. If so, how is that done?

Database engine: MySQL

Thanks in advance.

TB

Reply With Quote