I have multiple rows in a MySQL database and I wish to be swap the value of one field between two rows
I am not looking to switch the primary key ID, but a separate ID stored in another field, which I am using to determine the displayed order on a webpage. I can think of ways to do it through PHP, but they are very clunky. Is there a MySQL query that will handle this?
I currently have:
Article_ID | Title | Order_ID
1 | Article One | 1
2 | Article Two | 2
3 | Article Three | 3
I wish to switch the Order_IDs of rows 2 and 3, so that I end up with:
Article_ID | Title | Order_ID
1 | Article One | 1
2 | Article Two | 3
3 | Article Three | 2
switching the value of a field between two rows - MySQL
Moderator: General Moderators
-
SimonMayer
- Forum Commoner
- Posts: 32
- Joined: Wed Sep 09, 2009 6:40 pm
Re: switching the value of a field between two rows - MySQL
What SQL queries have you tried so far?
There are 10 types of people in this world, those who understand binary and those who don't