Lets say I have a column that has 20 rows (it’s more, but the concept will hold true for 20). Right now, the column is uniquely numbered 1-20. I need to figure out a query though that will change that number scheme from sequential, to sequential with just even or odd numbers.
So for example I just need to create a column in a table where it is numbered in even numbers, or odd numbers. So after the update query is run, it would change my column data from 1-20 to 2-40 (even numbers only), or 1-39 (odd numbers only).
I’m sorry if that doesn’t make sense, or if you can’t think of a reason why I’d need that, but in a strange sort of way, I do need it.
EDIT:
Due to the fact that this doesn’t make sense, I’ll try and clarify a little more.
I have a column that is currently ordered 1-10
1,2,3,4,5,6,7,8,9,10.
I want to execute an update query on the column so that it looks like this:
1,3,5,7,9,11,13,15,17,19
or
2,4,6,8,10,12,14,16,18,20
Is there an update query that I could run to do that?
For even numbers:
For odd numbers:
You can only run into trouble if your DBMS starts checking the column for uniqueness too soon, which is ultimately a flaw in (or limitation of) the DBMS. That is: while the ‘even’ update is running, there might be an as-yet-not-updated row containing value 2 as well as an already-updated row containing value 2 (originally 1). If the DBMS enforces uniqueness at each row, this will fail; but the DBMS is not supposed to do that.