DiscoTrio Posted March 15, 2010 Share Posted March 15, 2010 So im making a php button to click (like an up or down arrow) to re-order a table but first I need a way to re-assign the primary key 'id' that is auto-increment. Heres a quick look at the table: idmediatitlecontenttext 1photoSample item 1http://media-cdn.tripadvisor.com/media/photo-s/00/...Lorem ipsum dolor sit amet, consectetur adipiscing... 2videoSample item 2media/himmler-poznan-large.flvIn quis nisi tellus, ut gravida elit. Sed aliquet,... So anyways see the id? Its auto increment and primary... I need a sql statement to switch the two numbers that I can run from php variables. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/195370-swap-two-primary-keys/ Share on other sites More sharing options...
premiso Posted March 15, 2010 Share Posted March 15, 2010 You should be able to run an UPDATE on the primary and auto_increment id, albiet it is generally not recommended, instead it would be recommended to have a separate column for "order" and then order it by that and you can use that to display it. Quote Link to comment https://forums.phpfreaks.com/topic/195370-swap-two-primary-keys/#findComment-1026691 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.