> I want to create entries in the child table (table2) > for the missing records. In table2 the primary key is > of type Integer, > for each new entry it should be > Max(table2.PrimaryKeyfield) + 1.
Why not make the primary key in table2 autoincrement? If you have an autoincrement field as primary key MySQL will do the max(..)+1 automatically for you! A query like Insert into table2 (field1, field2) select a.field1, a.field2 from table1 a left join table2 b on (a.field1 = b.field1) where b.field1 is null could then be used to fill up the missing records in table2... Regards, Jigal. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]