I have to write a query wherein i need to allocate a ID (unique key) for a particular record which is not being used / is not being generated / does not exist i
ID
Should work under MySql.
SELECT TOP 100 T1.ID + 1 AS FREE_ID FROM TABLE1 T1 LEFT JOIN TABLE2 T2 ON T2.ID = T1.ID + 1 WHERE T2.ID IS NULL