Re: Need to swap primary keys - does mysql have a way?
There's not a native swap function. Find the first missing sequence number with
SELECT
a.pk + 1 AS 'Missing From',
MIN(b.pk) - 1 AS 'To'
FROM tbl AS a, tbl AS b
WHERE a.pk < b.pk
GROUP BY a.pk
HAVING a.pk < MIN(b.pk) - 1
ORDER BY a.pk+1 LIMIT 1;
PB
Subject
Written By
Posted
Re: Need to swap primary keys - does mysql have a way?
March 31, 2006 09:03AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.