DamienRoche Posted January 23, 2009 Share Posted January 23, 2009 Ok, so I want to increment/decrement a col (qid) but only after a certain number.... qid 1 2 3 4 5 I'm looking for a way to increment 3,4,5 to become 4,5,6 - by using an anchor that says increment all numbers after #num. Is that possible? Also, I want to be able to decrement numbers - so say, decrement 4,5 to become 4,3. NOTE: dupes don't matter. Is this possible? I need to be able to do this with mysql syntax within php, not phpmyadmin. I've searched but I just can't find anything that allows me to specify exactly where to increment/decrement. Any help greatly appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/142067-mysql-incrementdecrement-on-command-with-a-condition/ Share on other sites More sharing options...
dvd420 Posted January 23, 2009 Share Posted January 23, 2009 Hi if I m getting this correctly, u just need to execute the query: UPDATE <table_name> SET qid = qid + 1 WHERE qid > 3 Link to comment https://forums.phpfreaks.com/topic/142067-mysql-incrementdecrement-on-command-with-a-condition/#findComment-744101 Share on other sites More sharing options...
haku Posted January 23, 2009 Share Posted January 23, 2009 Out of curiosity - why? Link to comment https://forums.phpfreaks.com/topic/142067-mysql-incrementdecrement-on-command-with-a-condition/#findComment-744107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.