View Single Post

   
  #4 (permalink)  
Old 02-27-2008, 09:21 PM
Michael Stassen
 
Posts: n/a
Default Re: Conditional copy of values

Ravi Kumar. wrote:
> Dear All,
>
> I have 2 tables Table1 and Table2. In Table1 rowid is primary key and in
> Table2 rowid is primary key as well as foreign key (referring to rowid in
> Table1).
>
> There are several other columns in Table1, but Table2 has only one col -
> rowid.
>
> I want to insert rowid into Table2 conditionally:
>
> insert into Table2 (rowid) select T1.rowid from Table1 T1, Table2 T2
> where T1.somecolumn = 'some condition'
>
> But I want to insert only those rowid values which do not exist in T2.
>
> Please help.
>
> I am using MySQL version 4.1.14-standard-log. Hence subqueries are not a
> solution.


You've already got your solution, but, for the record, subqueries ARE supported
in mysql 4.1.14. They aren't supported in version prior to 4.1.

Michael
Reply With Quote