Tatjana Cukic <[EMAIL PROTECTED]> wrote on 10/07/2005 06:07:07 AM: > Hi, > > does anybody knows how i can add a new column to > Table1, where new column is made by substracting Col1 > from table Table1 and Col2 from Table2. Here is the > synthax: > > mysql> alter table Table1 add select(x.Col1-y.Col2) as > differentika from Table1 x,Table2 y where > x.Col3=y.Col3; > > Col3 is a primary key by Table2 > > Thanks! > Tatjana >
Sorry! You will need to do this in two steps. Step 1 creates the new column. Step 2 populates it. ALTER TABLE Table1 ADD differentika INT; /* or whatever data type is correct */ UPDATE Table1 x INNER JOIN Table2 y ON x.Col3 = y.Col3 SET x.differentika = x.Col1-y.Col2; Shawn Green Database Administrator Unimin Corporation - Spruce Pine